mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02:00
fix: 🐛 regression of flat keys separated by dot
This commit is contained in:
parent
f6c826497d
commit
d87caef060
|
@ -27,6 +27,12 @@ export function getMessageFromDictionary(locale: string, id: string) {
|
||||||
|
|
||||||
const localeDictionary = getLocaleDictionary(locale);
|
const localeDictionary = getLocaleDictionary(locale);
|
||||||
|
|
||||||
|
// flat ids
|
||||||
|
if (id in localeDictionary) {
|
||||||
|
return localeDictionary[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
// deep ids
|
||||||
const match = dlv(localeDictionary, id);
|
const match = dlv(localeDictionary, id);
|
||||||
|
|
||||||
return match;
|
return match;
|
||||||
|
|
|
@ -99,9 +99,9 @@ describe('getting messages', () => {
|
||||||
|
|
||||||
it('accepts english in dictionary keys', () => {
|
it('accepts english in dictionary keys', () => {
|
||||||
addMessages('pt', {
|
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?',
|
'E ai cara, como você vai hoje?',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user