From d87caef0600be10727222a2cfbe7ff391fb8ff4c Mon Sep 17 00:00:00 2001 From: Christian Kaisermann Date: Sun, 8 Nov 2020 19:09:45 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20regression=20of=20flat=20?= =?UTF-8?q?keys=20separated=20by=20dot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/runtime/stores/dictionary.ts | 6 ++++++ test/runtime/stores/dictionary.test.ts | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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?', ); });