mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-05 13:33:00 +00:00
improve(i18n): add locales for content.json, add code for server to i18n, build
This commit is contained in:
parent
7af95edc8c
commit
968c899836
12 changed files with 271 additions and 22 deletions
74
dist/habitrpg-shared.js
vendored
74
dist/habitrpg-shared.js
vendored
|
|
@ -10171,44 +10171,72 @@ gear = {
|
|||
},
|
||||
rogue: {
|
||||
0: {
|
||||
text: "Dagger",
|
||||
notes: 'A rogue\'s most basic weapon. Confers no benefit.',
|
||||
text: (function() {
|
||||
return i18n.t('weaponRogue0Text');
|
||||
}),
|
||||
notes: (function() {
|
||||
return i18n.t('weaponRogue0Notes');
|
||||
}),
|
||||
str: 0,
|
||||
value: 0
|
||||
},
|
||||
1: {
|
||||
text: "Short Sword",
|
||||
notes: 'Light, concealable blade. Increases STR by 2.',
|
||||
text: (function() {
|
||||
return i18n.t('weaponRogue1Text');
|
||||
}),
|
||||
notes: (function() {
|
||||
return i18n.t('weaponRogue1Notes');
|
||||
}),
|
||||
str: 2,
|
||||
value: 20
|
||||
},
|
||||
2: {
|
||||
text: "Scimitar",
|
||||
notes: 'Slashing sword, swift to deliver a killing blow. Increases STR by 3.',
|
||||
text: (function() {
|
||||
return i18n.t('weaponRogue2Text');
|
||||
}),
|
||||
notes: (function() {
|
||||
return i18n.t('weaponRogue2Notes');
|
||||
}),
|
||||
str: 3,
|
||||
value: 35
|
||||
},
|
||||
3: {
|
||||
text: "Kukri",
|
||||
notes: 'Distinctive bush knife, both survival tool and weapon. Increases STR by 4.',
|
||||
text: (function() {
|
||||
return i18n.t('weaponRogue3Text');
|
||||
}),
|
||||
notes: (function() {
|
||||
return i18n.t('weaponRogue3Notes');
|
||||
}),
|
||||
str: 4,
|
||||
value: 50
|
||||
},
|
||||
4: {
|
||||
text: "Nunchaku",
|
||||
notes: 'Heavy batons whirled about on a length of chain. Increases STR by 6.',
|
||||
text: (function() {
|
||||
return i18n.t('weaponRogue4Text');
|
||||
}),
|
||||
notes: (function() {
|
||||
return i18n.t('weaponRogue4Notes');
|
||||
}),
|
||||
str: 6,
|
||||
value: 70
|
||||
},
|
||||
5: {
|
||||
text: "Ninja-to",
|
||||
notes: 'Sleek and deadly as the ninja themselves. Increases STR by 8.',
|
||||
text: (function() {
|
||||
return i18n.t('weaponRogue5Text');
|
||||
}),
|
||||
notes: (function() {
|
||||
return i18n.t('weaponRogue5Notes');
|
||||
}),
|
||||
str: 8,
|
||||
value: 90
|
||||
},
|
||||
6: {
|
||||
text: "Hook Sword",
|
||||
notes: 'Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10.',
|
||||
text: (function() {
|
||||
return i18n.t('weaponRogue6Text');
|
||||
}),
|
||||
notes: (function() {
|
||||
return i18n.t('weaponRogue6Notes');
|
||||
}),
|
||||
str: 10,
|
||||
value: 120,
|
||||
last: true
|
||||
|
|
@ -11585,9 +11613,18 @@ _ = require('lodash');
|
|||
|
||||
module.exports = {
|
||||
strings: {},
|
||||
t: function(stringName, vars) {
|
||||
var string;
|
||||
string = module.exports.strings[stringName];
|
||||
translations: {},
|
||||
t: function(stringName) {
|
||||
var locale, string, stringNotFound, vars;
|
||||
vars = arguments[1];
|
||||
if (_.isString(arguments[1])) {
|
||||
vars = null;
|
||||
locale = arguments[1];
|
||||
} else if (arguments[2] != null) {
|
||||
vars = arguments[1];
|
||||
locale = arguments[2];
|
||||
}
|
||||
string = locale ? module.exports.translations[locale][stringName] : module.exports.strings[stringName];
|
||||
if (string) {
|
||||
if (vars) {
|
||||
return _.template(string, vars);
|
||||
|
|
@ -11595,7 +11632,8 @@ module.exports = {
|
|||
return string;
|
||||
}
|
||||
} else {
|
||||
return _.template(module.exports.strings.stringNotFound, {
|
||||
stringNotFound = locale ? module.exports.translations[locale].stringNotFound : module.exports.strings.stringNotFound;
|
||||
return _.template(stringNotFound, {
|
||||
string: stringName
|
||||
});
|
||||
}
|
||||
|
|
|
|||
20
locales/de/content.json
Normal file
20
locales/de/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/es/content.json
Normal file
20
locales/es/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/fr/content.json
Normal file
20
locales/fr/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/it/content.json
Normal file
20
locales/it/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/pl/content.json
Normal file
20
locales/pl/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/pt/content.json
Normal file
20
locales/pt/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/ru/content.json
Normal file
20
locales/ru/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/sk/content.json
Normal file
20
locales/sk/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/sv/content.json
Normal file
20
locales/sv/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
20
locales/uk/content.json
Normal file
20
locales/uk/content.json
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"weaponBase0Text": "No Weapon",
|
||||
"weaponBase0Notes": "No Weapon.",
|
||||
"weaponWarrior0Text": "Training Sword",
|
||||
"weaponWarrior0Notes": "Practice weapon. Confers no benefit.",
|
||||
"weaponWarrior1Text": "Sword",
|
||||
"weaponWarrior1Notes": "Common soldier's blade. Increases STR by 3.",
|
||||
"weaponWarrior2Text": "Axe",
|
||||
"weaponWarrior2Notes": "Double-bitted battle-axe. Increases STR by 6",
|
||||
"weaponWarrior3Text": "Morning Star",
|
||||
"weaponWarrior3Notes": "Heavy club with brutal spikes. Increases STR by 9.",
|
||||
"weaponWarrior4Text": "Sapphire Blade",
|
||||
"weaponWarrior4Notes": "Sword whose edge bites like the north wind. Increases STR by 12.",
|
||||
"weaponWarrior5Text": "Ruby Sword",
|
||||
"weaponWarrior5Notes": "Weapon whose forge-glow never fades. Increases STR by 15.",
|
||||
"weaponWarrior6Text": "Golden Sword",
|
||||
"weaponWarrior6Notes": "Bane of creatures of darkness. Increases STR by 18.",
|
||||
"weaponRogue0Text": "Hook Sword",
|
||||
"weaponRogue0Notes": "Complex weapon adept at ensnaring and disarming opponents. Increases STR by 10."
|
||||
}
|
||||
|
|
@ -1,11 +1,22 @@
|
|||
_ = require 'lodash'
|
||||
|
||||
module.exports =
|
||||
strings: {}
|
||||
t: (stringName, vars) ->
|
||||
string = module.exports.strings[stringName]
|
||||
strings: {}, # Strings for one single language
|
||||
translations: {} # Strings for multiple languages {en: strings, de: strings, ...}
|
||||
t: (stringName) -> # Other parameters allowed are vars (Object) and locale (String)
|
||||
vars = arguments[1]
|
||||
|
||||
if _.isString(arguments[1])
|
||||
vars = null
|
||||
locale = arguments[1]
|
||||
else if arguments[2]?
|
||||
vars = arguments[1]
|
||||
locale = arguments[2]
|
||||
|
||||
string = if locale then module.exports.translations[locale][stringName] else module.exports.strings[stringName]
|
||||
|
||||
if string
|
||||
if vars then _.template(string, vars) else string
|
||||
else
|
||||
_.template(module.exports.strings.stringNotFound, {string: stringName})
|
||||
stringNotFound = if locale then module.exports.translations[locale].stringNotFound else module.exports.strings.stringNotFound
|
||||
_.template(stringNotFound, {string: stringName})
|
||||
Loading…
Reference in a new issue