-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
9 changed files
with
305 additions
and
157 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,44 @@ | ||
import * as en from "./translations/en.json"; | ||
import * as nb from "./translations/nb.json"; | ||
|
||
const languages = { | ||
en: en, | ||
nb: nb, | ||
}; | ||
|
||
export class localise { | ||
private lang: string; | ||
|
||
constructor(preferred: string) { | ||
if (!(preferred in languages)) { | ||
preferred = preferred.substring(0, 2); | ||
if (!(preferred in languages)) { | ||
preferred = "en"; | ||
} | ||
} | ||
this.lang = preferred; | ||
} | ||
|
||
private find(language: string, keys: string[]) { | ||
let d = languages[language]; | ||
for (const k of keys) { | ||
d = d[k]; | ||
if (d === undefined) throw new Error(); | ||
} | ||
return d; | ||
} | ||
|
||
public t(key: string): string { | ||
const keys = key.split("."); | ||
try { | ||
return this.find(this.lang, keys); | ||
} catch (e) { | ||
try { | ||
if (this.lang !== "en") return this.find("en", keys); | ||
else return ""; | ||
} catch (e) { | ||
return ""; | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,39 @@ | ||
{ | ||
"common": { | ||
"version": "Version", | ||
"invalidConfiguration": "Invalid configuration" | ||
}, | ||
"editor": { | ||
"title": { "name": "Title (optional)" }, | ||
"showControllers": { "name": "Show controllers (CSV list)" }, | ||
"alwaysShowZones": { "name": "Always show zones" }, | ||
"alwaysShowSequences": { "name": "Always show sequences" }, | ||
"showTimelineScheduled": { "name": "Show timeline sheduled" }, | ||
"showTimelineHistory": { "name": "Show timeline history" } | ||
}, | ||
"controller": { | ||
"zones": { | ||
"name": "Zones", | ||
"buttonHint": "Show/hide zones" | ||
}, | ||
"sequences": { | ||
"name": "Sequences", | ||
"buttonHint": "Show/hide sequences" | ||
} | ||
}, | ||
"menu": { | ||
"enable": { "name": "Enable" }, | ||
"suspend": { | ||
"name": "Suspend", | ||
"hint": "Duration\n===============\nh:mm:ss\n<blank> = reset" | ||
}, | ||
"manual": { "name": "Manual", "hint": "Duration" }, | ||
"pause": { "name": "Pause" }, | ||
"resume": { "name": "Resume" }, | ||
"cancel": { "name": "Cancel" }, | ||
"adjust": { | ||
"name": "Adjust", | ||
"hint": "Adjustment options\n===============\nPercentage: %n\nActual: =0:00:00\nIncrease: +0:00:00\nDecrease: -0:00:00\nReset: <blank>" | ||
} | ||
} | ||
} |
Oops, something went wrong.