add "auto" language
This commit is contained in:
1 parent
acc049a418
commit
5505cbe309
5 files changed
+42
-14
No files matched your search
+13
-5
@@ -364,9 +364,9 @@ end
|
|||||||
-- falls back to english if it doesnt exist, unless specified otherwise
|
-- falls back to english if it doesnt exist, unless specified otherwise
|
||||||
function EID:getDescriptionEntry(objTable, objID, noFallback)
|
function EID:getDescriptionEntry(objTable, objID, noFallback)
|
||||||
if not objID then
|
if not objID then
|
||||||
return EID.descriptions[EID.Config["Language"]][objTable] or EID.descriptions["en_us"][objTable]
|
return EID.descriptions[EID:getLanguage()][objTable] or EID.descriptions["en_us"][objTable]
|
||||||
else
|
else
|
||||||
local translatedTable = EID.descriptions[EID.Config["Language"]][objTable]
|
local translatedTable = EID.descriptions[EID:getLanguage()][objTable]
|
||||||
if noFallback then return translatedTable and translatedTable[objID]
|
if noFallback then return translatedTable and translatedTable[objID]
|
||||||
else return (translatedTable and translatedTable[objID]) or (EID.descriptions["en_us"][objTable] and EID.descriptions["en_us"][objTable][objID]) end
|
else return (translatedTable and translatedTable[objID]) or (EID.descriptions["en_us"][objTable] and EID.descriptions["en_us"][objTable][objID]) end
|
||||||
end
|
end
|
||||||
@@ -450,7 +450,7 @@ function EID:getTransformationName(id)
|
|||||||
-- get translated custom name
|
-- get translated custom name
|
||||||
local customTransform = EID.CustomTransformations[id]
|
local customTransform = EID.CustomTransformations[id]
|
||||||
if customTransform ~= nil then
|
if customTransform ~= nil then
|
||||||
return customTransform[EID.Config["Language"]] or customTransform["en_us"] or id
|
return customTransform[EID:getLanguage()] or customTransform["en_us"] or id
|
||||||
end
|
end
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
@@ -1210,7 +1210,7 @@ end
|
|||||||
|
|
||||||
-- Function to fix font compatibility. Resets config font to a value compatible with your current language
|
-- Function to fix font compatibility. Resets config font to a value compatible with your current language
|
||||||
function EID:fixDefinedFont()
|
function EID:fixDefinedFont()
|
||||||
local curLang = EID.Config["Language"]
|
local curLang = EID:getLanguage()
|
||||||
local curFont = EID.Config["FontType"]
|
local curFont = EID.Config["FontType"]
|
||||||
for _, v in ipairs(EID.descriptions[curLang].fonts) do
|
for _, v in ipairs(EID.descriptions[curLang].fonts) do
|
||||||
if curFont == v.name then
|
if curFont == v.name then
|
||||||
@@ -1224,7 +1224,7 @@ function EID:fixDefinedFont()
|
|||||||
end
|
end
|
||||||
-- Check if a given font name is valid for the currently selected language
|
-- Check if a given font name is valid for the currently selected language
|
||||||
function EID:canUseFontType(fontType)
|
function EID:canUseFontType(fontType)
|
||||||
local curLang = EID.Config["Language"]
|
local curLang = EID:getLanguage()
|
||||||
for _, v in ipairs(EID.descriptions[curLang].fonts) do
|
for _, v in ipairs(EID.descriptions[curLang].fonts) do
|
||||||
if fontType == v.name then
|
if fontType == v.name then
|
||||||
return true
|
return true
|
||||||
@@ -1313,3 +1313,11 @@ function EID:checkPlayersForMissingItems()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function EID:getLanguage()
|
||||||
|
local lang = EID.Config["Language"]
|
||||||
|
if lang == "auto" then
|
||||||
|
return Options and EID.LanguageMap[Options.Language] or "en_us"
|
||||||
|
end
|
||||||
|
return lang
|
||||||
|
end
|
||||||
+4
-3
@@ -1,7 +1,8 @@
|
|||||||
EID.UserConfig = {
|
EID.UserConfig = {
|
||||||
-------GENERAL---------
|
-------GENERAL---------
|
||||||
-- Change the language of the mod
|
-- Change the language of the mod
|
||||||
-- Currently Supported: English = "en_us" (Default), "en_us_detailed" (More detailed descriptions)
|
-- Currently Supported: auto = "auto" (Default) Same as Options->Language(Rep), or English(ab+)
|
||||||
|
-- English = "en_us", "en_us_detailed" (More detailed descriptions)
|
||||||
-- French = "fr" SPECIAL THANKS TO Nicolas Delvaux
|
-- French = "fr" SPECIAL THANKS TO Nicolas Delvaux
|
||||||
-- Polish = "pl" SPECIAL THANKS TO Rickyy
|
-- Polish = "pl" SPECIAL THANKS TO Rickyy
|
||||||
-- Spanish = "spa" SPECIAL THANKS TO Lidia Arroyo Purroy
|
-- Spanish = "spa" SPECIAL THANKS TO Lidia Arroyo Purroy
|
||||||
@@ -16,7 +17,7 @@ EID.UserConfig = {
|
|||||||
--
|
--
|
||||||
-- If you want to make a translation, please contact me :) (wofsauge)
|
-- If you want to make a translation, please contact me :) (wofsauge)
|
||||||
--
|
--
|
||||||
["Language"] = "en_us",
|
["Language"] = "auto",
|
||||||
-- Change if item names should be displayed in English, your translated language or both
|
-- Change if item names should be displayed in English, your translated language or both
|
||||||
-- States: 1 = English , 2 = translated, 3 = both
|
-- States: 1 = English , 2 = translated, 3 = both
|
||||||
-- Default = 2
|
-- Default = 2
|
||||||
@@ -374,7 +375,7 @@ EID.UserConfig = {
|
|||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
EID.DefaultConfig = {
|
EID.DefaultConfig = {
|
||||||
["Language"] = "en_us",
|
["Language"] = "auto",
|
||||||
["TranslateItemName"] = 2,
|
["TranslateItemName"] = 2,
|
||||||
["FontType"] = "default",
|
["FontType"] = "default",
|
||||||
["TextboxWidth"] = 130,
|
["TextboxWidth"] = 130,
|
||||||
|
|||||||
@@ -516,3 +516,10 @@ EID.GoldenTrinketData = {
|
|||||||
EID.BreakUtf8CharsLanguage = {
|
EID.BreakUtf8CharsLanguage = {
|
||||||
['zh_cn'] = true
|
['zh_cn'] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EID.LanguageMap = {
|
||||||
|
["ru"] = "ru",
|
||||||
|
["de"] = "de",
|
||||||
|
["kr"] = "ko_kr",
|
||||||
|
["zh"] = "zh_cn",
|
||||||
|
}
|
||||||
@@ -538,7 +538,7 @@ function EID:printDescription(desc)
|
|||||||
local curName = desc.Name
|
local curName = desc.Name
|
||||||
if EID.Config["TranslateItemName"] ~= 2 then
|
if EID.Config["TranslateItemName"] ~= 2 then
|
||||||
local curLanguage = EID.Config["Language"]
|
local curLanguage = EID.Config["Language"]
|
||||||
if curLanguage ~= "en_us" then
|
if EID:getLanguage() ~= "en_us" then
|
||||||
EID.Config["Language"] = "en_us"
|
EID.Config["Language"] = "en_us"
|
||||||
local englishName = desc.PermanentTextEnglish or EID:getObjectName(desc.ObjType, desc.ObjVariant, desc.ObjSubType)
|
local englishName = desc.PermanentTextEnglish or EID:getObjectName(desc.ObjType, desc.ObjVariant, desc.ObjSubType)
|
||||||
EID.Config["Language"] = curLanguage
|
EID.Config["Language"] = curLanguage
|
||||||
@@ -612,7 +612,7 @@ function EID:printBulletPoints(description, renderPos)
|
|||||||
local textScale = Vector(EID.Scale, EID.Scale)
|
local textScale = Vector(EID.Scale, EID.Scale)
|
||||||
description = EID:replaceShortMarkupStrings(description)
|
description = EID:replaceShortMarkupStrings(description)
|
||||||
for line in string.gmatch(description, "([^#]+)") do
|
for line in string.gmatch(description, "([^#]+)") do
|
||||||
local formatedLines = EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID.Config["Language"]])
|
local formatedLines = EID:fitTextToWidth(line, textboxWidth, EID.BreakUtf8CharsLanguage[EID:getLanguage()])
|
||||||
local textColor = EID:getTextColor()
|
local textColor = EID:getTextColor()
|
||||||
for i, lineToPrint in ipairs(formatedLines) do
|
for i, lineToPrint in ipairs(formatedLines) do
|
||||||
-- render bulletpoint
|
-- render bulletpoint
|
||||||
|
|||||||
+16
-4
@@ -280,18 +280,30 @@ if MCMLoaded then
|
|||||||
{
|
{
|
||||||
Type = ModConfigMenu.OptionType.NUMBER,
|
Type = ModConfigMenu.OptionType.NUMBER,
|
||||||
CurrentSetting = function()
|
CurrentSetting = function()
|
||||||
return AnIndexOf(EID.Languages, EID.Config["Language"])
|
if EID.Config["Language"] == "auto" then
|
||||||
|
return #(EID.Languages) + 1
|
||||||
|
else
|
||||||
|
return AnIndexOf(EID.Languages, EID.Config["Language"])
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
Minimum = 1,
|
Minimum = 1,
|
||||||
Maximum = #(EID.Languages),
|
Maximum = #(EID.Languages) + 1, -- add "auto" language
|
||||||
Display = function()
|
Display = function()
|
||||||
EID.MCMCompat_isDisplayingEIDTab = "Visuals"
|
EID.MCMCompat_isDisplayingEIDTab = "Visuals"
|
||||||
return "Language: " .. displayLanguage[AnIndexOf(EID.Languages, EID.Config["Language"])]
|
if EID.Config["Language"] == "auto" then
|
||||||
|
return "Language: auto(" .. displayLanguage[AnIndexOf(EID.Languages, EID:getLanguage())] .. ")"
|
||||||
|
else
|
||||||
|
return "Language: " .. displayLanguage[AnIndexOf(EID.Languages, EID.Config["Language"])]
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
OnChange = function(currentNum)
|
OnChange = function(currentNum)
|
||||||
EID.MCM_OptionChanged = true
|
EID.MCM_OptionChanged = true
|
||||||
EID.RefreshBagTextbox = true -- Crafting isn't open so it won't notice MCM_OptionChanged, but definitely needs to refresh
|
EID.RefreshBagTextbox = true -- Crafting isn't open so it won't notice MCM_OptionChanged, but definitely needs to refresh
|
||||||
EID.Config["Language"] = EID.Languages[currentNum]
|
if currentNum == #(EID.Languages) + 1 then
|
||||||
|
EID.Config["Language"] = "auto"
|
||||||
|
else
|
||||||
|
EID.Config["Language"] = EID.Languages[currentNum]
|
||||||
|
end
|
||||||
local isFixed = EID:fixDefinedFont()
|
local isFixed = EID:fixDefinedFont()
|
||||||
if isFixed then
|
if isFixed then
|
||||||
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")
|
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")
|
||||||
|
|||||||
Reference in new issue
Block a user