forked from 0ad/0ad
Some i18n fixed on the JavaScript side
Do not try to translate empty strings in translateObjectKeys(). Do not try to translate empty formation tooltips. Do not translate player names at a point where they are already translated. This was SVN commit r15005.
This commit is contained in:
parent
f5b0fc1076
commit
4770e64449
@ -3,6 +3,18 @@ var g_pluralTranslations = {};
|
||||
var g_translationsWithContext = {};
|
||||
var g_pluralTranslationsWithContext = {};
|
||||
|
||||
// Checks if the specified variable is a string, and if it is, it checks that it
|
||||
// is not empty.
|
||||
function isNonEmptyString(variable)
|
||||
{
|
||||
if (typeof variable != "string")
|
||||
return false;
|
||||
else if (variable.trim())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// Translates the specified English message into the current language.
|
||||
//
|
||||
// This function relies on the g_translations cache when possible. You should use this function instead of
|
||||
@ -157,7 +169,7 @@ function translateObjectKeys(object, keys) {
|
||||
{
|
||||
if (keys.indexOf(property) > -1)
|
||||
{
|
||||
if (typeof object[property] == "string")
|
||||
if (isNonEmptyString(object[property]))
|
||||
object[property] = translate(object[property]);
|
||||
else if (object[property] instanceof Object)
|
||||
{
|
||||
@ -177,7 +189,7 @@ function translateObjectKeys(object, keys) {
|
||||
{
|
||||
if (property in keys)
|
||||
{
|
||||
if (typeof object[property] == "string")
|
||||
if (isNonEmptyString(object[property]))
|
||||
if (keys[property])
|
||||
object[property] = translateWithContext(keys[property], object[property]);
|
||||
else
|
||||
|
@ -633,7 +633,7 @@ function setupUnitPanel(guiName, usedPanels, unitEntState, playerState, items, c
|
||||
{
|
||||
grayscale = "grayscale:";
|
||||
|
||||
// Display a meaningful tooltip why the formation is disabled
|
||||
if (formationInfo.tooltip)
|
||||
button.tooltip += "\n" + "[color=\"red\"]" + translate(formationInfo.tooltip) + "[/color]";
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ function getPlayerData(playerAssignments)
|
||||
{
|
||||
var playerState = simState.players[i];
|
||||
|
||||
var name = translate(playerState.name);
|
||||
var name = playerState.name;
|
||||
var civ = playerState.civ;
|
||||
var color = {
|
||||
"r": playerState.colour.r*255,
|
||||
|
Loading…
Reference in New Issue
Block a user