Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Feb 18, 2020
1 parent f064ba3 commit aa35e41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/localize.android.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { vsprintf } from "sprintf-js";
import { android as _android } from "tns-core-modules/application";
import { getString, setString } from "tns-core-modules/application-settings";
import { isAndroid } from "tns-core-modules/platform";
import * as utils from "tns-core-modules/utils/utils";
import { getString, setString } from 'tns-core-modules/application-settings';
import { isAndroid } from 'tns-core-modules/platform';
import { android as _android } from 'tns-core-modules/application';

import { encodeKey } from "./resource";

Expand Down Expand Up @@ -30,7 +30,7 @@ export function localize(key: string, ...args: string[]): string {
}

export function androidLaunchEventLocalizationHandler() {
const lang = getString('__app__language__', 'none');
const lang = getString("__app__language__", 'none');
if (lang !== 'none' && isAndroid) {
const locale = new java.util.Locale(lang);
java.util.Locale.setDefault(locale);
Expand All @@ -44,7 +44,6 @@ export function androidLaunchEventLocalizationHandler() {
}

export function overrideLocale(locale: string): boolean {
setString('__app__language__', locale.substring(0, 2));

setString("__app__language__", locale.substring(0, 2));
return true;
}
2 changes: 2 additions & 0 deletions src/localize.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export declare function localize(key: string, ...args: string[]): string;

export declare function overrideLocale(locale: string): boolean;

export declare function androidLaunchEventLocalizationHandler(): void;
4 changes: 2 additions & 2 deletions src/localize.ios.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { vsprintf } from "sprintf-js";
import { setString } from "tns-core-modules/application-settings";

import { convertAtSignToStringSign } from "./placeholder";
import { encodeKey } from "./resource";
import { setString } from "tns-core-modules/application-settings";

let bundle;

Expand Down Expand Up @@ -34,7 +34,7 @@ export function overrideLocale(locale: string): boolean {
bundle = NSBundle.bundleWithPath(path);
NSUserDefaults.standardUserDefaults.setObjectForKey([locale], "AppleLanguages");
NSUserDefaults.standardUserDefaults.synchronize();
setString('__app__language__', locale.substring(0, 2));
setString("__app__language__", locale.substring(0, 2));

return true;
}

0 comments on commit aa35e41

Please sign in to comment.