Skip to content

Commit

Permalink
Make sure flow tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytro-gokun committed Mar 29, 2019
1 parent a5f8daa commit 2cbeeac
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
54 changes: 20 additions & 34 deletions src/ui/localization/ui-translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,36 @@ import uk from './uk';

const SupportedUiLanguages = {
'en': {},
'uk': uk
uk
};

class UiTranslator
{
_strings: object;
class UiTranslator {
_strings: Object;

constructor(uiLanguage?: string, uiLanguagePatch?: object) {
switch (typeof uiLanguage) {
case 'string':
this._strings = SupportedUiLanguages[uiLanguage];
if (this._strings === undefined) {
warnOnce(`uiLanguage '${uiLanguage}' is not supported`);
this._strings = {};
}
break;

case 'null':
case 'undefined':
this._strings = {};
break;

default:
warnOnce(`'uiLanguage' expected to be a string but it is '${typeof uiLanguage}'`);
constructor(uiLanguage: ?string, uiLanguagePatch: ?Object) {
if (uiLanguage == null) {
this._strings = {};
} else if (typeof uiLanguage === 'string') {
this._strings = SupportedUiLanguages[uiLanguage];
if (this._strings === undefined) {
warnOnce(`uiLanguage '${uiLanguage}' is not supported`);
this._strings = {};
break;
}
} else {
warnOnce(`'uiLanguage' expected to be a string but it has type '${typeof uiLanguage}'`);
this._strings = {};
}

switch (typeof uiLanguagePatch) {
case 'object':
if (uiLanguagePatch != null) {
if (typeof uiLanguagePatch === 'object') {
this._strings = extend(clone(this._strings), uiLanguagePatch);
break;

case 'null':
case 'undefined':
break;

default:
warnOnce(`'uiLanguagePatch' expected to be an object but it is '${typeof uiLanguagePatch}'`);
break;
} else {
warnOnce(`'uiLanguagePatch' expected to be an object but it has type '${typeof uiLanguagePatch}'`);
}
}
}

translate(key: string): string | undefined {
translate(key: string): ?string {
return this._strings[key];
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/ui/localization/uk.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow

const uk = {
'FullscreenControl.EnterTooltip': 'Повноекранний режим',
'FullscreenControl.ExitTooltip': 'Вийти з повноекранного режиму',
Expand Down
2 changes: 1 addition & 1 deletion src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type MapOptions = {
maxTileCacheSize?: number,
transformRequest?: RequestTransformFunction,
uiLanguage?: string,
uiLanguagePatch?: object
uiLanguagePatch?: Object
};

const defaultMinZoom = 0;
Expand Down

0 comments on commit 2cbeeac

Please sign in to comment.