Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/internal/LocalizedString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { LocalizedStringSchema } from '../types/schema';
* LocalizedString.setGlobalLocale('jp');
* locStr.localString; // Japanese String
*/
class LocalizedString implements LocalizedStringSchema {
class LocalizedString implements LocalizedStringSchema, Iterable<[string, string]> {
private static globalLocale = 'en';

[x: string]: string;
Expand Down Expand Up @@ -43,6 +43,12 @@ class LocalizedString implements LocalizedStringSchema {
if (locale.length < 2 || locale.length > 8) throw Error(`Locale "${locale}" has an invalid length`);
LocalizedString.globalLocale = locale;
}

*[Symbol.iterator](): IterableIterator<[string, string]> {
for (const [key, value] of Object.entries(this)) {
if (key !== 'globalLocale') yield [key, value];
}
}
}

export default LocalizedString;