-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
008bc84
commit a5f8daa
Showing
4 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// @flow | ||
|
||
import { clone, extend, warnOnce } from '../../util/util'; | ||
import uk from './uk'; | ||
|
||
const SupportedUiLanguages = { | ||
'en': {}, | ||
'uk': uk | ||
}; | ||
|
||
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}'`); | ||
this._strings = {}; | ||
break; | ||
} | ||
|
||
switch (typeof uiLanguagePatch) { | ||
case '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; | ||
} | ||
} | ||
|
||
translate(key: string): string | undefined { | ||
return this._strings[key]; | ||
} | ||
} | ||
|
||
export default UiTranslator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const uk = { | ||
'FullscreenControl.EnterTooltip': 'Повноекранний режим', | ||
'FullscreenControl.ExitTooltip': 'Вийти з повноекранного режиму', | ||
}; | ||
|
||
export default uk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters