Skip to content

Commit df0be20

Browse files
update stringsCache to use language (#24)
1 parent 148821d commit df0be20

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/index.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default class OtaClient {
8585
private manifestHolder?: Promise<Manifest>;
8686
private disableManifestCache = false;
8787

88-
private stringsCache: { [file: string]: Promise<any> } = {};
88+
private stringsCache: { [file: string]: { [language: string]: Promise<any> } } = {};
8989
private disableStringsCache = false;
9090

9191
private disableJsonDeepMerge = false;
@@ -273,13 +273,16 @@ export default class OtaClient {
273273
let strings = {};
274274
for (const filePath of files) {
275275
let content;
276-
if (!!this.stringsCache[filePath]) {
277-
content = await this.stringsCache[filePath];
276+
if (!!(this.stringsCache[filePath] || {})[language]) {
277+
content = await this.stringsCache[filePath][language];
278278
} else {
279279
if (!this.disableStringsCache) {
280-
this.stringsCache[filePath] = this.getFileTranslations(filePath, language);
280+
this.stringsCache[filePath] = {
281+
...this.stringsCache[filePath],
282+
[language]: this.getFileTranslations(filePath, language),
283+
};
281284
}
282-
content = await this.stringsCache[filePath];
285+
content = await this.stringsCache[filePath][language];
283286
}
284287
if (this.disableJsonDeepMerge) {
285288
strings = { ...strings, ...content };

0 commit comments

Comments
 (0)