Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon titles and descriptions made translatable #4984

Merged
merged 6 commits into from Jul 9, 2020

Conversation

kabachuha
Copy link
Member

Addon titles and descriptions made translatable

Hello, wesnoth devs!

The international wesnoth players had long been troubled by not being able to see what the addon is about without installing it or using external tools. So I decided to make it possible to see addon titles and descriptions in the addon manager.

I've done through [translation] tag modification because sending .mo file for the entire campaign is unnecesearily, and .mo and .po workflow just for .pbl file is redundant.

The feature is done on the master branch, but I'd like backporting it to 1.14 in after it's tested.

The original tag contains only the language attribute, the new one has the following structure. (If the declaration is abscent, but the .mo file is present, it'll be added with supported=yes attribute.):

[translation]
	description="localized description"
	language="ru" #locale code
	supported=yes #is set to yes if the corresponding .mo file has been found, otherwise no. If the client receives the tag without the `supported` attribute, it's assumed as `yes` for backward compatibility.
	title="localized title"
[/translation]

To upload the description translation insert it into the .pbl file.

The example .pbl file
  author="kabachuha"
  title="Hello World"
  icon="units/monsters/gryphon.png"
  version="0.1.0"
  description="Checking the translation of the addon!"
  type="campaign"
  email="artemkhrapov2001@yandex.ru"
  passphrase="iloveasaltycucumber"
  translate=true

  [translation]
  	language="ru"
  	title="Здравствуй, мир!"
  	description="Проверка перевода описания аддона"
  [/translation]

  [translation]
  	language="zh_CN"
  	title="你好,世界!"
  	description="检查插件的翻译 (translated online)"
  [/translation]

Notice: My testing addon also has a .mo file for the Japanese translation which isn't declared in this file. But you'll see it in the server database with supported=yes.

The deal with the supported attribute is to protect against an edge case when the translation is declared without the .mo file (as pointed out by Iris (@shikadiqueen) and against duplicate translations.

The server stores the addon info as usual except for the appended translation tags.

The server.cfg from my testing addon server
  compress_level=6
  [campaigns]
  	[campaign]
  		author="kabachuha"
  		description="Checking the translation of the addon!"
  		downloads=1
  		email="artemkhrapov2001@yandex.ru"
  		filename="data/Hello_World"
  		icon="units/monsters/gryphon.png"
  		name="Hello_World"
  		original_timestamp=1593893863
  		passhash="hs3F0Q1wNL2b2xWTn5ODS1"
  		passsalt="nfOLTKWsrjS/s6v2"
  		size=776987
  		timestamp=1593899194
  		title="Hello World"
  		translate=true
  		type="campaign"
  		upload_ip="127.0.0.1"
  		uploads=7
  		version="0.1.0"
  		[translation]
  			description="Проверка перевода описания аддона"
  			language="ru"
  			supported=yes
  			title="Здравствуй, мир!"
  		[/translation]
  		[translation]
  			description="检查插件的翻译 (translated online)"
  			language="zh_CN"
  			supported=no
  			title="你好,世界!"
  		[/translation]
  		[translation]
  			language="ja"
  			supported=yes
  		[/translation]
  	[/campaign]
  	[campaign]
  		author="kabachuha"
  		description="Addon with no translation for Russian!"
  		downloads=0
  		email="artemkhrapov2001@yandex.ru"
  		filename="data/Status_Quo_Addon"
  		icon="units/monsters/gryphon.png"
  		name="Status_Quo_Addon"
  		original_timestamp=1593894760
  		passhash="E6D1VGjAb5bXqxK/KAWKH0"
  		passsalt="oMGowk3uSHic9QY0"
  		size=3656
  		timestamp=1593894760
  		title="Status Quo"
  		translate=true
  		type="campaign"
  		upload_ip="127.0.0.1"
  		uploads=1
  		version="0.1.0"
  		[translation]
  			description="检查插件的翻译 (translated online)"
  			language="zh_CN"
  			supported=no
  			title="你好,世界!"
  		[/translation]
  	[/campaign]
  [/campaigns]

The client side will check if the translation exists for the current locale and will use the translated title (the original title is shown slightly below the title for players who had known the addon by the English name) and the translated description in that case.

Also, I made possible to search both for the original and the translated strings in the manager.

Demos

Pictures

The changes are fully backwards compatible with the old server/client.

backward_compatible

Addons on my pet server.

2020-07-05-005141_1920x1080_scrot

Chinese translation is rendered fine too.

2020-07-05-005233_1920x1080_scrot

Uploadable addons are also translated and the search is possible.

2020-07-05-004724_1920x1080_scrot

Known issue

The addon's name may not be fully shown in the dependecies window if it's very long. (According to Iris and Vultraz, its the fault of the gui even without the translation, so it belongs to another issue).

Modified the `translation` tag in the addon structure and made the translated names shown in the corresponding locale on the client side.

See the related pull-request for more information.
It's needed for the stored translation info.
@irydacea irydacea requested a review from Vultraz July 6, 2020 05:50
Copy link
Member

@irydacea irydacea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the server-side changes and some of the backend client-side changes. The UI parts touch on stuff that's a bit beyond my area of expertise at the moment.

src/addon/info.hpp Outdated Show resolved Hide resolved
src/addon/info.cpp Outdated Show resolved Hide resolved
src/addon/info.cpp Outdated Show resolved Hide resolved
src/addon/info.cpp Outdated Show resolved Hide resolved
src/campaign_server/addon_utils.cpp Outdated Show resolved Hide resolved
src/campaign_server/campaign_server.cpp Outdated Show resolved Hide resolved
src/campaign_server/addon_utils.cpp Outdated Show resolved Hide resolved
src/campaign_server/campaign_server.cpp Outdated Show resolved Hide resolved
src/campaign_server/campaign_server.cpp Show resolved Hide resolved
@kabachuha kabachuha requested a review from irydacea July 6, 2020 21:22
@kabachuha
Copy link
Member Author

I think I made all the requested changes. Also tested them with my pet server, everything looks fine so far.

@Wedge009 Wedge009 added Add-ons Issues with the add-ons client and/or server. Translations Issues with translations, translation tooling, the translations engine, or code that uses it. labels Jul 6, 2020
@Pentarctagon
Copy link
Member

One of the travis jobs is failing: https://travis-ci.com/github/wesnoth/wesnoth/jobs/358117144#L707

(Hopefully)
@kabachuha
Copy link
Member Author

Fixed it, @Pentarctagon.

src/addon/info.cpp Outdated Show resolved Hide resolved
src/addon/info.cpp Outdated Show resolved Hide resolved
src/campaign_server/addon_utils.cpp Outdated Show resolved Hide resolved
src/campaign_server/campaign_server.cpp Outdated Show resolved Hide resolved
src/addon/info.cpp Outdated Show resolved Hide resolved
@irydacea irydacea self-assigned this Jul 7, 2020
@irydacea irydacea added the UI User interface issues, including both back-end and front-end issues. label Jul 7, 2020
Changed the pointers to references where possible. Some variable type fixes.
@kabachuha kabachuha requested a review from irydacea July 7, 2020 08:11
Copy link
Member

@Vultraz Vultraz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick read-over since Iris already did a fuller review. Everything looks alright.

@irydacea irydacea merged commit dac172c into wesnoth:master Jul 9, 2020
kabachuha added a commit to kabachuha/wesnoth that referenced this pull request Jul 13, 2020
Pentarctagon pushed a commit that referenced this pull request Jul 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Add-ons Issues with the add-ons client and/or server. Translations Issues with translations, translation tooling, the translations engine, or code that uses it. UI User interface issues, including both back-end and front-end issues.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants