Thread Tools Display Modes
11/01/22, 02:45 AM   #1
Lykeion
 
Lykeion's Avatar
AddOn Author - Click to view addons
Join Date: May 2022
Posts: 17
Question Is it possible for an addon to control the i18n files used by other addons?

I've recently been working on helping my localization team with the bilingualization of ESO. We have a great plugin that allows ESO to display our local language and English at the same time, which greatly facilitates communication between our local language players and English speakers.

But we are having some problems. Our bilingual mode needs to use its own language code, just as EN for English and FR for French. This poses the problem that even if an addon implements i18n, it will obviously not have a string file corresponding to the language code of our bilingual version. Even if it has our local language version, its language will fall back to English by default in bilingual mode.

My team can customize this for common addons by making a copy of our local language string file and saving it as a bilingual language code version. But that's obviously not a smart way to go. Is it possible to have an addon that maps the language used by other addons to B when it detects a language environment of A?

Last edited by Lykeion : 11/01/22 at 03:43 AM.
  Reply With Quote
11/01/22, 06:41 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
There are multiple ways to overwrite localization files of other addons:

If they e.g. include a folder in their addon's zip file which overwrites the other addons folder/files.
Or if the other addon's i81n files are globally accessible.
Or if the other addon is using ZOs vanilla way of adding i18n via ZO_CreateStringId, then other addons can create the same with a higher version overwriting them.


For your use case:
I cannot imagine any way to achieve what you like to, or I missunderstand what you need?
I think you can have 1 fallback language, e.g. using ZO_CreateStringId and always laoding the en.lua file first, then load the <$Lang>.lua file.
or if you have a custom i18n table you my use metatables of lua to always find the "en" table entry if the current client language is missing that particular string.

But if you want to find another "fallback" you need to "point" to that, either globally for your whole addon using metatables, or manually per string in your addon's respective i18n table/file.


If you want to have more logic you need to write an addon doing this and "overwriting" as described in my first lines of this post.

Last edited by Baertram : 11/01/22 at 07:19 AM.
  Reply With Quote
11/01/22, 11:06 AM   #3
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Originally Posted by Lykeion View Post
Is it possible to have an addon that maps the language used by other addons to B when it detects a language environment of A?
The simple answer is no. You can make your own personal mod create strings and use ZO_CreateStringId(key, value) and SafeAddVersion(key, 1) to override localization but you can not completely override a mods functionality to display the language.

For me if it's any of my mods that I support/maintain then I have a GitHub for all of them. Just make a pull request.

What is the language? Do you just translate mods or are have you modified the UI itself as well?

I for one don't approve of unofficial translations where somebody has uploaded mods by myself or other authors to an unknown site that people go to download the mod because it has the special localization in it. The Unofficial Polish translation used to have files included with an exe installer that would overwrite an author's mods and I don't approve of that process either. Both methods usually use outdated versions of the mod.

Last edited by Sharlikran : 11/01/22 at 11:21 AM.
  Reply With Quote
11/01/22, 11:35 AM   #4
Lykeion
 
Lykeion's Avatar
AddOn Author - Click to view addons
Join Date: May 2022
Posts: 17
Originally Posted by Sharlikran View Post
What is the language? Do you just translate mods or are have you modified the UI itself as well?
The language I am referring to in this sentence is basically i18n files, such as en.lua, fr.lua and so on. Let's say my bilingual mode uses the language code fe, and I want eso to look for fr.lua first when the language code is fe, and then fall back to en.lua (or whatever the author specifies as the default language) if it doesn't exist. This is what I want to achieve.

Thanks to your answers, it looks like it is difficult to implement the features I envisioned on ESO at this time. Maybe in the future my team and I can come up with a smarter solution to solve the addon localization and bilingual mode incompatibility problem once and for all.

Last edited by Lykeion : 11/01/22 at 11:41 AM.
  Reply With Quote
11/01/22, 01:58 PM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
If you want to have a logic you need to add the traslation strings to an internal table with the language constant fe and en in seperate subtables.
Create yourself a function that returns either fe or en entries then, based on your logic (e.g. use fr for all except some controls that you have defined in another table).
Or something similar.

The entries in those internal tables cannot use ZO_CreateString though as the default string constants are client language dependent -> if you use GetString to read them.
So you'd have to manually translate the string in the internal tables of your addon.
  Reply With Quote
11/01/22, 02:14 PM   #6
Sharlikran
 
Sharlikran's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 626
Originally Posted by Lykeion View Post
The language I am referring to in this sentence is basically i18n files, such as en.lua, fr.lua and so on. Let's say my bilingual mode uses the language code fe
Yeah lets not call it fe, unless it really is fe. So that support can be added to addons now rather then attempting to make some hacked up code. I can load my game in any of ten different languages so one more won't be an issue. Most of my mods support all ten languages. Some are just not translated well enough because someone made a translation and then I have never heard from them again. If you are willing to translate any of my mods I'm happy to accept the translation.

Now if it is a variation of French like the difference between Spanish from Mexico or Spain, or French from France or French from Quebec then using fe makes sense. However, it should be added to the wiki and established as a standard so all authors know about it. Then nobody will try to use it to mean something else.

https://wiki.esoui.com/How_to_add_localization_support

Originally Posted by Lykeion View Post
I want eso to look for fr.lua first when the language code is fe, and then fall back to en.lua
There is no API for that, not possible. There is no need for that. It's not a standard method of doing things.

Once you use SetCVar("Language.2", "fe") it will be in fe only, period.

You can have Lua files load in this fashion.
Lua Code:
  1. i18n\en.lua -- load regardless of SetCVar()
  2. i18n\$(language).lua -- only loads the language set by SetCVar()
But first and foremost that must be in the authors mod. You can not alter or change that because it's part of the manifest file for the mod. So again no fallback, and also no outside control from another mod. The game will read the masifest.txt file at load time and that's it.

This is similar to what Baertram is getting at. It is not a fallback though.

If an author specifies en then the $(language), it will make it such that all the English strings are assigned first using ZO_CreateStringId(), and then if the same constant is used in the fe.lua file then whatever you put in ZO_CreateStringId() will be in fe.

Originally Posted by Lykeion View Post
(or whatever the author specifies as the default language) if it doesn't exist
You can not override the languages the author has provided in the manner you want.

Originally Posted by Lykeion View Post
Thanks to your answers
You are welcome and I am happy to help.

Originally Posted by Lykeion View Post
it looks like it is difficult to implement the features I envisioned on ESO at this time.
Not difficult, not possible.

Originally Posted by Lykeion View Post
Maybe in the future my team and I can come up with a smarter solution to solve the addon localization and bilingual mode incompatibility problem once and for all.
Not possible now or in the near future. That's not how it works.

So the TLDR is: What is the real language you are using and if you provide your bilingual mod I can look at it and make any improvements. Most likely what you want to achieve is not truly possible and only works in certain cases. So let the community help.

The solution would then be to translate the mods and let the authors use the translations.

Right now I can think of myself and at least 5 other authors that would use your translations in their mods.

Also if you are just translating mods but you want to translate the entire UI I can help get that set up the same as it is done for Korean, Italian, Ukrainian, Polish, and Portuguese. Chinese and Spanish were unofficial translations in the past but they are official and included with the game as of the latest patch.

Last edited by Sharlikran : 11/01/22 at 08:14 PM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Is it possible for an addon to control the i18n files used by other addons?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off