fmasa / wfrp-master

Unofficial Android companion app for 4th edition of Warhammer Fantasy Roleplay
GNU General Public License v3.0
11 stars 3 forks source link

Multilanguage Support #24

Closed Joly0 closed 1 year ago

Joly0 commented 1 year ago

Hey, i have been using your app and it works great so far, though to recommend this app to friends of mine, it would be great, if there was multilanguage support. My friends arent that familiar with english, so it would be hard for them to use this otherwise great tool. If contributors could add their own languages to this app, it would be a great addition.

fmasa commented 1 year ago

Hi, there are two options IMO.

"Official" translation in app

Pros
Cons

Translations import

Pros
Cons

Right now I'm not sure I want to support the first option. The second one I'm not sure.

Do you have a particular language in mind?

Joly0 commented 1 year ago

My idea on this was about using generic placeholders in the app for text fields and let contributors add new languages through resource files and if a field is not yet translated, then default to english. How the translated files get loaded in the app could either be at build time so in the released apk is the latest language changes included. Otherwise it should be possible to dynamically load the languages on the go.

Though this is just my view on this. In my case the needed language would be german and i would be happy to help translate the app later, when this feature is implemented

fmasa commented 1 year ago

@Joly0 Most of the values is currently externalized in Strings class as string placeholders. There are a few lambdas that I'll rewrite to string placeholders as well. Then I'll think about some injection points for the translations.

Joly0 commented 1 year ago

Hey, any news on this one? :D

fmasa commented 1 year ago

@Joly0 As I mentioned, everything is already externalized to single place - the Strings class, the app does not use Android resource files (it's written as a multiplatform app).

Note, that the strings often change as new features are added or changed, sometimes as often as several times per month. So keeping this up to date will not be easy task and my German is so poor I cannot do this myself :grinning:. I'll gladly accept the PR, but will not maintain this myself, if you want, I can ping you in PRs that would break the translations if possible.

If you still want to do this, this would be the approach:

Create PR with German translations: This can be as simple as a new German.kt file in https://github.com/fmasa/wfrp-master/tree/master/common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/localization with top-level val:

val German = Strings(
    socialStatusBrass = "Gold",
    // ...
)

This way, all German users can benefit from the translations. When this PR is ready, I would gladly implement the little logic necessary for locale switching.

fmasa commented 1 year ago

@Joly0, @Stilzkin I am moving the translations to separate resource files for more straightforward translations and I will also set up a Weblate project so that anyone can contribute the translations. I expect this to be ready around this weekend.

Stilzkin commented 1 year ago

Hi! I've completed the Italian translation of Strings.kt (4 hr well spent :D) but i dont know how to implement in the project (im fresh new to github).

Italian.zip

Joly0 commented 1 year ago

@Joly0, @Stilzkin I am moving the translations to separate resource files for more straightforward translations and I will also set up a Weblate project so that anyone can contribute the translations. I expect this to be ready around this weekend.

Sounds great, i am already hyped for it and ready for translating :D

fmasa commented 1 year ago

Hi! I've completed the Italian translation of Strings.kt (4 hr well spent :D) but i dont know how to implement in the project (im fresh new to github).

Great, thank you! I'll add it on my side once I'm done with the some necessary changes. I'll also write some basic instructions for translation submissions. :slightly_smiling_face:

Sounds great, i am already hyped for it and ready for translating :D

I'm looking forward to it! :slightly_smiling_face:

fmasa commented 1 year ago

@Stilzkin I processed everything and set up Weblate as a tool that would simplify contributions. You can see that there are still a few translations missing in Italian (https://hosted.weblate.org/projects/wfrp-master/glossary/). Also, I encountered some inconsistencies (NPCS are sometimes called PNG, and sometimes NPC), would you mind taking a look? :slightly_smiling_face:

You can submit the changes directly there and the Weblate should notify me, so I can automatically apply these translations.

Also please note, that changes hitting this GitHub repository (master branch more specifically) are not immediately available in the app. The changes become available only after I tag a new release. I'll document this in more detail in a few days.


@Joly0 You can take a look at Weblate now as it should be possible to add a new language :slightly_smiling_face: Alternatively if you are familiar with git, the https://github.com/fmasa/wfrp-master/commit/957f6727b322b993da492a205984d581855a8ef0 can work as inspiration for direct contribution as PR.

Stilzkin commented 1 year ago

@Stilzkin I processed everything and set up Weblate as a tool that would simplify contributions. You can see that there are still a few translations missing in Italian (https://hosted.weblate.org/projects/wfrp-master/glossary/). Also, I encountered some inconsistencies (NPCS are sometimes called PNG, and sometimes NPC), would you mind taking a look? 🙂

You can submit the changes directly there and the Weblate should notify me, so I can automatically apply these translations.

Also please note, that changes hitting this GitHub repository (master branch more specifically) are not immediately available in the app. The changes become available only after I tag a new release. I'll document this in more detail in a few days.

@Joly0 You can take a look at Weblate now as it should be possible to add a new language 🙂 Alternatively if you are familiar with git, the 957f672 can work as inspiration for direct contribution as PR.

Nice work @fmasa ! I look for corrections asap!

Stilzkin commented 1 year ago

OK, I translated the remaining strings and fixed a few things (including NPC / PNG). One question: where are the names of the Conditions? I didn't see them in the file.

fmasa commented 1 year ago

I see now that Conditions are not translatable, I'll fix that.

fmasa commented 1 year ago

@Stilzkin I accepted your translations https://github.com/fmasa/wfrp-master/pull/152.

I also merged https://github.com/fmasa/wfrp-master/pull/151, so Conditions can now be translated.

Stilzkin commented 1 year ago

@Stilzkin I accepted your translations #152.

I also merged #151, so Conditions can now be translated.

Conditions translated 😉

fmasa commented 1 year ago

@Stilzkin Would you take a look once more? There are additional fields to translate because I added Trapping compendiums (a way to import Trappings from CRB, Winds of Magic, and Up in Arms).

As mentioned, this is not a problem as any missing translation will fall back into English. But I think it would be awesome if the first release with Italian support would have 100% translation. I don't plan any other significant changes for 3.14.0, so don't worry that I would be asking this every week :grinning:

Also, in the future, there will almost certainly be changes in UI that will bring new strings that could use a translation. AFAIK Weblate supports notifications when new strings are available.

Stilzkin commented 1 year ago

@Stilzkin Would you take a look once more? There are additional fields to translate because I added Trapping compendiums (a way to import Trappings from CRB, Winds of Magic, and Up in Arms).

As mentioned, this is not a problem as any missing translation will fall back into English. But I think it would be awesome if the first release with Italian support would have 100% translation. I don't plan any other significant changes for 3.14.0, so don't worry that I would be asking this every week 😀

Also, in the future, there will almost certainly be changes in UI that will bring new strings that could use a translation. AFAIK Weblate supports notifications when new strings are available.

Done :)

fmasa commented 1 year ago

Closing this issue, as it's done from my side. Anyone who wants to contribute can read the instructions at https://github.com/fmasa/wfrp-master/wiki/Translations

@Joly0 as mentioned in WIKI, just open a new issue once you finish the German translation and I'll add it to the next version :slightly_smiling_face: