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

item: let translators reorder tname segments #77885

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

andrei8l
Copy link
Contributor

@andrei8l andrei8l commented Nov 15, 2024

Summary

None

Purpose of change

Item name segments are printed in a hardcoded order that makes sense in English but maybe not so much in other languages.

Describe the solution

Read the segment order from a translatable string
This string is fixed in English (tname_segments_order) so that translator-specified order still works when translations are out of sync with new segments.
New segments that aren't specified in tname_segments_order are printed at the end of the name in hardcoded order
The CONTENTS segment (and any after it) has a fixed place and can't be changed

Describe alternatives you've considered

N/A

Testing

New test unit

Manual testing:

I changed the order for es_ES to place `BURN` after `TYPE`
diff --git a/lang/po/es_ES.po b/lang/po/es_ES.po
index 4bc10148c9..35295a8cbb 100644
--- a/lang/po/es_ES.po
+++ b/lang/po/es_ES.po
@@ -87,6 +87,9 @@ msgstr ""
 "Los alimentos fríos duran más. Busca un sótano fresco o haz una bodega de "
 "raíces."
 
+msgid "tname_segments_order"
+msgstr "FAULTS DIRT OVERHEAT FAVORITE_PRE DURABILITY WHEEL_DIAMETER WEAPON_MODS CUSTOM_ITEM_PREFIX TYPE BURN CATEGORY CUSTOM_ITEM_SUFFIX MODS CRAFT WHITEBLACKLIST CHARGES FOOD_TRAITS FOOD_STATUS FOOD_IRRADIATED TEMPERATURE LOCATION_HINT CLOTHING_SIZE ETHEREAL FILTHY BROKEN CBM_STATUS UPS TAGS VARS WETNESS ACTIVE SEALED FAVORITE_POST RELIC LINK TECHNIQUES"
+
 #. ~ Snippet in category "tip"
 #: data/core/tips.json
 msgid "Dying is part of the experience.  Try again with what you've learned."
@@ -718618,7 +718621,7 @@ msgstr "muy quemado"
 #: src/item_tname.cpp:115
 msgctxt "burnt adjective"
 msgid "burnt "
-msgstr "quemado"
+msgstr " quemado"
 
 #: src/item_tname.cpp:181
 #, c-format

Screenshot From 2024-11-15 16-28-19

Additional context

I'm concerned that this is too convoluted and has low visibility. It seems pretty fragile too.

Uwuewsky can you take a look? You asked about this on discord a few months ago.

@Maleclypse
Copy link
Member

translate item name

I'm a little confused by this. It looks like from how transifex is setup that I could order the name however I wanted to in the translate box. I'm probably misunderstanding what is being targeted here.

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` new contributor labels Nov 15, 2024
@andrei8l
Copy link
Contributor Author

I'm a little confused by this. It looks like from how transifex is setup that I could order the name however I wanted to in the translate box. I'm probably misunderstanding what is being targeted here.

This is for tname which is constructed from various descriptors along with the type name. So if you burn a trenchcoat, the game will print burnt trenchcoat from discrete strings burnt and trenchcoat. In Spanish, French, and some other languages we support that word order is wrong - it should be noun adjective and this PR should let translators fix that.

@Maleclypse
Copy link
Member

This is for tname which is constructed from various descriptors along with the type name. So if you burn a trenchcoat, the game will print burnt trenchcoat from discrete strings burnt and trenchcoat. In Spanish, French, and some other languages we support that word order is wrong - it should be noun adjective and this PR should let translators fix that.

That's really cool. Thank you for doing this!

@github-actions github-actions bot added astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions labels Nov 15, 2024
@Uwuewsky
Copy link
Contributor

Yep, thank you, that would be really helpful.

I'm concerned that this is too convoluted and has low visibility.

You can add a comment to std::string order_i18n( _( "tname_segments_order" ) ); that will describe this feature, or a link to the documentation/source code.

@github-actions github-actions bot added the Code: Tests Measurement, self-control, statistics, balancing. label Nov 15, 2024
@andrei8l
Copy link
Contributor Author

You can add a comment to std::string order_i18n( _( "tname_segments_order" ) ); that will describe this feature, or a link to the documentation/source code.

There's a translation comment here and I've verified that it gets exported to the .pot file
https://github.com/CleverRaven/Cataclysm-DDA/pull/77885/files#diff-a464990ac7e4d49006af861a2e2b354e33516889e89107509cc7f26602bbdae7R725-R732
Feel free to suggest fluffier or better wording.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Nov 15, 2024
@andrei8l andrei8l marked this pull request as ready for review November 15, 2024 21:04
@Night-Pryanik Night-Pryanik merged commit 71f5bb9 into CleverRaven:master Nov 16, 2024
38 of 44 checks passed
@andrei8l
Copy link
Contributor Author

Thanks for merging

@andrei8l andrei8l deleted the tname-reorder branch November 16, 2024 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. json-styled JSON lint passed, label assigned by github actions new contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants