Plugin inline translations

Learn here how to create and use plugins.

Moderator: Plugin Moderators

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Plugin inline translations

#1

Post by Lobby »

Until now the only way to translate plugins was by doing it hardcoded in the project itself. That means you weren't able to provide translations for your own plugins and rather had to offer different variants in order to offer localization.

Version 1.5.56 will solve that by introducing inline translations for plugins. The way this will work is by using a special syntax within the plugin. Let's have a look at this example from the wandering animals plugin:

Code: Select all

"title":"Wandering animals"
That's how the title definition looks right now. This notion will still work in the future, but we can append specialized translations to it by writing [languagetag]Translation. For example for the case of a German translation that would look like:

Code: Select all

"title":"Wandering animals[de]Streunende Tiere"
You can append as many specialized translations as you want to. The game will then pick that one that's closest to the current language. The first case (here the English one without []) will be used as a fallback translation if no other translation does fit. I recommend to use English for it.

This special syntax will also work for the text attribute.

Note that only languages that are supported by the game naively can be translated that way. Have a look at the public translation repository for the supported language codes right now.

User avatar
CommanderABab
AB
Reactions:
Posts: 11086
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Plugin inline translations

#2

Post by CommanderABab »

When using foreign alphabets with QuickEdit, be sure to change the Default Encoding for files from auto detect to one of the encodings that includes your alphabet. Otherwise the next time you load it the foreign alphabet will look like this: "????? ?????????? ??????". :/

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Plugin inline translations

#3

Post by Lobby »

I recommend to use UTF8 whenever possible.

User avatar
Pederont
Villager
Reactions:
Posts: 24
Joined: 10 Aug 2019, 09:01
Location: South Korea
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Plugin inline translations

#4

Post by Pederont »

Inline translation doesn't work with requirement text?

User avatar
CommanderABab
AB
Reactions:
Posts: 11086
Joined: 07 Jun 2016, 21:12
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Plugin inline translations

#5

Post by CommanderABab »

You would have to provide the language tags in the text [RU]текст, [EN]text, etc

User avatar
Mako1137
Inhabitant of a Megacity
Reactions:
Posts: 164
Joined: 05 Dec 2021, 22:31
Location: Sacramento, CA
Plugins: Showcase Store
Contact:

Platform

Re: Plugin inline translations

#6

Post by Mako1137 »

Can you please add the Filipino language? I'm an inactive speaker.
Language tag: [tl].

@Lobby

User avatar
Naufhal
Inhabitant of a Supercluster
Reactions:
Posts: 3742
Joined: 07 Oct 2021, 06:04
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Plugin inline translations

#7

Post by Naufhal »

Filipino language is already added in game setting.

User avatar
Mako1137
Inhabitant of a Megacity
Reactions:
Posts: 164
Joined: 05 Dec 2021, 22:31
Location: Sacramento, CA
Plugins: Showcase Store
Contact:

Platform

Re: Plugin inline translations

#8

Post by Mako1137 »

Naufhal wrote:
21 Aug 2022, 03:49
Filipino language is already added in game setting.
I meant the language tag at the Github

User avatar
Naufhal
Inhabitant of a Supercluster
Reactions:
Posts: 3742
Joined: 07 Oct 2021, 06:04
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Plugin inline translations

#9

Post by Naufhal »

Probably b+fil are filipino.

User avatar
Lakan Haraya
Metropolitan
Reactions:
Posts: 131
Joined: 28 Mar 2019, 09:34
Location: Philippines
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Plugin inline translations

#10

Post by Lakan Haraya »

@Mako1137
Heya! Use [fil] instead of [tl] for that ;)

Code: Select all

"text":"Hello![fil]Kumusta!"

User avatar
Pederont
Villager
Reactions:
Posts: 24
Joined: 10 Aug 2019, 09:01
Location: South Korea
Plugins: Showcase Store
Contact:

Plugin Creator

Platform

Re: Plugin inline translations

#11

Post by Pederont »

Code: Select all

"requirements":[{
"type":"CONDITION", 
"data":{"condition":{"type":"building count", "id":"$containment_building_02_pederont", "min":0, "max":0}, 
"text": "Must not own upgraded building[ko]업그레이드한 건물이 없어야 합니다"}
}]
I wanted inline translation on requirement text but it just prints entire text.

Post Reply Previous topicNext topic

Return to “Tutorials and Documentation”