Skip to content

Commit

Permalink
fix: 🐛 regression of flat keys separated by dot
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann committed Nov 8, 2020
1 parent f6c8264 commit d87caef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/runtime/stores/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/runtime/stores/dictionary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?',
);
});
Expand Down

0 comments on commit d87caef

Please sign in to comment.