Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

RageLeague

Inheriting base language for modded languages

Recommended Posts

RageLeague    1491

For a modded language, you often don't have much time to keep your translation up to date, and even if you do, you can't possibly keep up with all the different mods that add new, localizable strings to the game. If your modded language is based on an existing language, you may want to use existing language as a fallback, since a mediocre translation is often better than no translations. So how would you do that?

I have written a code in case you want to inherit a base language, and here it is:

-- Let the localization whose id is new_id inherit the localization files of base_id.
-- Useful for defining fallback strings if the mod is not kept up to date, or loading localization files
-- added to the base language from another mod.
-- Example: Better Chinese Simplified(https://steamcommunity.com/sharedfiles/filedetails/?id=2234153945)
-- inherits the localization files of the base game Chinese Simplified language as a fallback.
--
-- BaseLocalization("chinese_simplified", "chs")
local function BaseLocalization(base_id, new_id)
	local old_loc = Content.GetLocalizations()[base_id]
	local new_loc = Content.GetLocalizations()[new_id]
	if old_loc and new_loc then
		new_loc.po_filenames = new_loc.po_filenames or {}
		for i, filename in ipairs(old_loc.po_filenames) do
			table.insert_unique(new_loc.po_filenames, filename)
		end
	end
end

It adds the localization files of the existing language to the new language.

To use it, copy this code to your modinit file, and call the function after your Content.AddLocalization(settings). For example:

local function OnPreLoad( mod )
    Content.AddLocalization(settings)
    BaseLocalization(base_language_id, settings.id)
    Content.AddPOFileToLocalization(settings.id, po_file_path)
end

It is a very useful function that the devs may add it to the base game, but just in case they didn't, you can use this code. It saves me the trouble of updating mod load order every time a new language mod is added to the workshop.

Share this post


Link to post
Share on other sites
johnruby    45
On 1/25/2021 at 12:21 AM, RageLeague said:

For a modded language, you often don't have much time to keep your translation up to date, and even if you do, you can't possibly keep up with all the different mods that add new, localizable strings to the game. If your modded language is based on an existing language, you may want to use existing language as a fallback, since a mediocre translation is often better than no translations. So how would you do that?

I have written a code in case you want to inherit a base language, and here it is:

This is AMAZINGLY useful for my mod. Thank you so much for sharing your code!

As a newbie modder, I'm currently working on an Improved Traditional Chinese mod, and I was worrying that the next patch which is going to be released tomorrow will make the mod unplayable for quite a while, since the game shows original English text whenever it finds no corresponding translated text from the mod. Now the subscribers can keep using the mod without worrying about un-translated English text.

Here's my modinit.lua, in case there're other newbie modders as me wanting to create improved translation mod:

Quote


local settings = 
{
    id = "cht",
    motd_key = "zh_hant",
    name = "繁體中文(改良版)",
    font_settings = 
    {
        title = { font = "fonts/notosans_cn_sdf.zip", sdfthreshold = 0.38, sdfboldthreshold = 0.37, supportsitalics = false },
        body = { font = "fonts/notosans_cn_sdf.zip", sdfthreshold = 0.45, sdfboldthreshold = 0.38, supportsitalics = false },
        button = { font = "fonts/notosans_cn_sdf.zip", sdfthreshold = 0.45, sdfboldthreshold = 0.35, supportsitalics = false },
        tooltip = { font = "fonts/notosans_cn_sdf.zip", sdfthreshold = 0.45, sdfboldthreshold = 0.35, supportsitalics = false },
        speech = { font = "fonts/notosans_cn_sdf.zip", sdfthreshold = 0.45, sdfboldthreshold = 0.35, supportsitalics = false },
    },

    demo_logo_image = "large/logo_hant_demo.tex",
    logo_image = "large/logo_hant.tex",

    default_languages = 
    {
        "zh-HANT",
        "zh-HK",
        "zh-MO",
        "zh-TW",
    }

}

-- base_id = chinese_traditional
-- new_id = cht

local function BaseLocalization(base_id, new_id)
    local old_loc = Content.GetLocalizations()[base_id]
    local new_loc = Content.GetLocalizations()[new_id]
    if old_loc and new_loc then
        new_loc.po_filenames = new_loc.po_filenames or {}
        for i, filename in ipairs(old_loc.po_filenames) do
            table.insert_unique(new_loc.po_filenames, filename)
        end
    end
end


local function OnPreLoad( mod )
    Content.AddLocalization(settings)
    BaseLocalization("chinese_traditional", "cht")
    Content.AddPOFileToLocalization(settings.id, "CHT:zh_hant_better.po")
end

    
return
{
    alias = "CHT",
    OnPreLoad = OnPreLoad,

    title = "繁體中文(改良版)\nTraditional Chinese\n(Improved Version)",
    description = "【最後更新日期】\n2021年1月26日\n【使用方法】\n在遊戲語言設定選擇「繁體中文(改良版)」即可。\n【模組功能】\n由於官方版本的繁體中文翻譯內容有些語意不太精確,有些則混用了簡體中文用語,造成繁體中文使用者閱讀上的困難,因此這個 mod 希望能提供玩家一個翻譯品質更好的繁體中文遊戲體驗。\nMade by johnruby",
    previewImagePath = "preview.jpg",
}

 

Share this post


Link to post
Share on other sites