Skip to content

Commit 6bf56f5

Browse files
authored
fix(localize): handle ios null key fixes #46 (#74)
1 parent e9a1662 commit 6bf56f5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/localize/hooks/data.provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class DataProvider {
6565

6666
if (!this.defaultLanguage) {
6767
this.defaultLanguage = this.languages.keys().next().value;
68-
this.logger.warn(`No file found with the .default extension: default langage set to '${this.defaultLanguage}'`);
68+
this.logger.warn(`No file found with the .default extension: default language set to '${this.defaultLanguage}'`);
6969
}
7070

7171
const defaultLanguageI18nEntries = this.languages.get(this.defaultLanguage);

packages/localize/index.ios.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ const getBundle = (function () {
1616
})();
1717

1818
export function localize(key: string, ...args: string[]): string {
19-
const localizedString = getBundle().localizedStringForKeyValueTable(encodeKey(key), key, null);
19+
let localizedString;
20+
try {
21+
localizedString = getBundle().localizedStringForKeyValueTable(encodeKey(key), key, null);
22+
} catch (error) {
23+
localizedString = key;
24+
}
2025
return vsprintf(convertAtSignToStringSign(localizedString), args);
2126
}
2227

0 commit comments

Comments
 (0)