After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 723511 - Status messages might be difficult to localize
Status messages might be difficult to localize
Status: RESOLVED FIXED
Product: four-in-a-row
Classification: Applications
Component: general
3.10.x
Other Linux
: Normal normal
: ---
Assigned To: four-in-a-row-maint
four-in-a-row-maint
Depends on:
Blocks:
 
 
Reported: 2014-02-03 03:53 UTC by Michael Catanzaro
Modified: 2014-09-01 16:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for the bug (3.64 KB, patch)
2014-03-21 16:51 UTC, Nikhar
needs-work Details | Review
Improved Patch (3.66 KB, patch)
2014-03-22 08:37 UTC, Nikhar
committed Details | Review
Clean up translation of player "name" (1.26 KB, patch)
2014-09-01 16:10 UTC, Michael Catanzaro
committed Details | Review

Description Michael Catanzaro 2014-02-03 03:53:20 UTC
E.g.

      str = g_strdup_printf (_("%s’s Turn"), who);

I imagine that could be difficult or impossible to localize.  This is a more serious issue now that these messages are displayed in the header bar instead of the status bar.
Comment 1 Michael Catanzaro 2014-02-14 23:44:44 UTC
Some more detail, since I suppose I am not the only one who needs to read these bugs:

The %s in the example above is going to be a color, Red or Green or Blue, or for high-contrast themes the name of a shape. These are defined in theme.c.  Appending to that string works fine in many languages, but it could be impossible to translate into other languages. Instead, we need to write out the strings in full, e.g. "Red’s Turn" and "Red Wins!"  The easiest way to do this would probably be to expand the struct in theme.h with fields for each of the needed strings, written out in full.  This might seem a bit messy, but stuff like this is not uncommon when dealing with translatable strings.

Also, note that modern GNOME programs use the curly apostrophe ’ rather than the ' key on your keyboard.
Comment 2 Michael Catanzaro 2014-03-08 03:52:05 UTC
So, briefly, there are two stages to translating open source programs: internationalization (i18n) and localization (l10n).  l10n is the process of translating, and a l10n bugs would be problems with individual translations. As a developer, I don't really care about those (in the sense that they're not my problem -- I can't fix a bad translation if I don't know that language). In contrast, i18n is the process of preparing text for l10n, and that is the developer's responsibility.

To make a string translatable, we use GNU gettext [1]. If you pass a string to the gettext() function, it becomes translatable. GNOME programs use a macro _ which expands to gettext to make this less annoying. (In Vala, it's a function, since Vala has no macros.) For example:

string s1 = "I am untranslatable. I'm not displayed to the user.";
string s2 = _("I am translatable, display me please!");

So marking strings for translation is clearly pretty simple. But there are a few gotchas. For example, if you add two strings together, you have to be super careful, since you could make the string impossible to translate correctly, as in the first post in this report:

str = g_strdup_printf (_("%s’s Turn"), who);

That works great for English, but in other languages, the string 'who' may need to be translated differently depending on context, and it might not necessarily belong at the start of the string, either. Instead, we have to mark the entirety of the string for translation, so we need separate _("Red’s Turn") _("Green’s Turn") _("Red Wins!") etc.

[1] https://www.gnu.org/software/gettext/
Comment 3 Nikhar 2014-03-21 16:51:14 UTC
Created attachment 272578 [details] [review]
Patch for the bug

Hi,

Kindly find my proposed patch for this bug attached. Do let me know if it's what you are looking for.

Thanks.
Comment 4 Michael Catanzaro 2014-03-21 22:26:44 UTC
Review of attachment 272578 [details] [review]:

That looks like it will work.

I think it would be better to expand the existing struct with two more fields, rather than adding two news structs. Notice that those structs are mostly redundant with the existing one, and you only need the last field of each.
Comment 5 Nikhar 2014-03-22 08:37:05 UTC
Created attachment 272618 [details] [review]
Improved Patch

Hi,

I have now expanded the original struct instead of using two additional ones.
Let me know if this is fine.
Comment 6 Michael Catanzaro 2014-03-22 15:43:39 UTC
Review of attachment 272618 [details] [review]:

Much better, thanks!
Comment 7 Claude Paroz 2014-09-01 07:40:45 UTC
Hi, I just wanted to note that this line will in no way translate the content of 'who':

g_strdup_printf (_("%s"), who);

gettext will translate "%s", which is unnecessary, then replace the untranslated 'who' variable into it. gettext must be called on the who variable, not on the "%s".

As the modification will simply remove translatable strings, not modify or add strings, this can be changed without requiring string freeze exception.
Comment 8 Michael Catanzaro 2014-09-01 16:09:27 UTC
Right, but we did call gettext on the line above, so there's no functional change here -- just a code cleanup, right?
Comment 9 Michael Catanzaro 2014-09-01 16:10:55 UTC
Double-check me on this please. :)  Thanks for reopening!

The following fix has been pushed:
03a4e8c Clean up translation of player "name"
Comment 10 Michael Catanzaro 2014-09-01 16:10:57 UTC
Created attachment 285031 [details] [review]
Clean up translation of player "name"
Comment 11 Claude Paroz 2014-09-01 16:34:47 UTC
Thanks, looks fine now.