diff --git a/src/runtime/stores/dictionary.ts b/src/runtime/stores/dictionary.ts index bd19f21..a23cbdc 100644 --- a/src/runtime/stores/dictionary.ts +++ b/src/runtime/stores/dictionary.ts @@ -27,6 +27,12 @@ export function getMessageFromDictionary(locale: string, id: string) { const localeDictionary = getLocaleDictionary(locale); + // flat ids + if (id in localeDictionary) { + return localeDictionary[id]; + } + + // deep ids const match = dlv(localeDictionary, id); return match; diff --git a/test/runtime/stores/dictionary.test.ts b/test/runtime/stores/dictionary.test.ts index 6bbc2c2..f6c2289 100644 --- a/test/runtime/stores/dictionary.test.ts +++ b/test/runtime/stores/dictionary.test.ts @@ -99,9 +99,9 @@ describe('getting messages', () => { it('accepts english in dictionary keys', () => { addMessages('pt', { - 'Hey man, how are you today?': 'E ai cara, como você vai hoje?', + 'Hey man. How are you today?': 'E ai cara, como você vai hoje?', }); - expect(getMessageFromDictionary('pt', 'Hey man, how are you today?')).toBe( + expect(getMessageFromDictionary('pt', 'Hey man. How are you today?')).toBe( 'E ai cara, como você vai hoje?', ); });