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

add support for translations using gettext #121

Merged
merged 11 commits into from
Aug 29, 2018
Merged

add support for translations using gettext #121

merged 11 commits into from
Aug 29, 2018

Conversation

andy5995
Copy link
Contributor

@andy5995 andy5995 commented Aug 25, 2018

I've separated some of my tasks under separate commits, so if you view them individually, you'll understand the changes a little better.

You can see some hints I've added in my commit messages.

po template file. This is updated automatically and shouldn't be edited.
This should have been included in an earlier commit, but you'll get the
idea xD
Any time a new language is added, you add it to the LINGUAS file.

Here's an example:

https://github.com/theimpossibleastronaut/rmw/blob/master/po/LINGUAS
Marked some more strings.

Regenerated bric.pot (`cd po && make update-po`)
@@ -1579,7 +1582,7 @@ int handle_tag_movement(int where) {
strcpy(orig_filename, Editor.filename);
if(where == MOVE_BACK) {
if(isempty(&tag_stack)) {
editor_set_status_message("at bottom of tag stack");
editor_set_status_message(_("at bottom of tag stack"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This string my be ambiguous to translators. https://www.gnu.org/software/gettext/manual/html_node/Preparing-Strings.html#Preparing-Strings

I assume "you are" is implied, but in some languages, grammar changes depending on the subject, so I suggest leaving a TRANSLATOR note here or adjusting the string.

}
if(key[0] == '\0') {
editor_set_status_message("No identifier under cursor");
editor_set_status_message(_("No identifier under cursor"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"identifier" may be ambiguous. I suggest leaving a TRANSLATOR note describing what an identifier specifically refers to.

@@ -1461,7 +1463,8 @@ void editor_goto(int linenumber)
editor_refresh_screen();
return;
} else {
editor_set_status_message("Out of bounds");
/* TRANSLATORS: alternate meaning: "exceeds boundary" */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an example of a TRANSLATOR note. You can see in the .pot file that these notes are added to the template, so translators will see them as they are translating po files.

@@ -2192,7 +2200,7 @@ int main(int argc, char **argv)
if(!is_file_locked(CurrentFile)){
lock_file(CurrentFile);
}else{
fprintf(stderr, "The file has been locked, try to remove the locker!\n");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"locker" will likely be ambiguous to translators. I suggest adjusting the string or leaving a TRANSLATOR note with a specific description of what locker refers to.

The extra space means they are an exact match, which means the redundant
string in the pot file will be removed.
Also, the 4 lines removed in Makefile.am aren't needed after adding this
to configure.ac
To test, I translated one line in Dutch, and it works. :)

```
andy@oceanus:~/src/bric/install_test/bin$ LANG=nl_NL.utf8 ./bric
Gebruik: bric <bestandsnaam>
```

This not only requires the translation in bric, but for the user to have
the locale installed on his system, if I'm not mistaken.

I already had the This locale installed. to install on Debian Linux

https://wiki.debian.org/Locale#Manually

#: src/bric.c:2186
#, c-format
msgid "Usage: bric <filename>\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sexybiggetje this is what I translated to test initial support for internationalization.

And yes, you know I'll be asking you to translate this whole file after this PR is merged. xD

@martijndeb
Copy link
Contributor

Please find the attached zip file. Github doesn't allow the po file directly.
I also shared some common language notes. Doing it this way because I don't have commit acces to this branch.

#: src/bric.c:1878 src/bric.c:1883 src/bric.c:1887 src/bric.c:1893
#: src/bric.c:1911 src/bric.c:1915
msgid “Insert mode. ”
msgstr “Invoeg modus. ”

It has a space at the end.
Normal mode later in the file doesnt
#. TRANSLATORS: “Bric” is the program name and should not be translated
#: src/bric.c:918
#, c-format
msgid “Bric editor -- version %s[0K\r\n”
msgstr “Bric editor -- versie %s[0K\r\n”
Ends with \r\n
#: src/bric.c:2203
#, c-format
msgid “The file has been locked, try to remove the locker!\n”
msgstr “Het bestand is vergrendeld, probeer de locker te verwijderen!\n”
Ends with \n
All should be \r\n or \n methinks.
#: src/bric.c:1492
#, c-format
msgid “There are unsaved changes, quit? (y or n) %s”
msgstr “Er zijn onopgeslagen wijzigingen, afsluiten? (y of n) %s”
should be j of n, (ja of nee) in dutch, but I kept y/n because keymap should change then as well
#. TRANSLATORS: “bric” is the program name, do not translate
#: src/bric.c:704
#, c-format
msgid “bric: invalid option -- ‘%c’\n”
msgstr “bric: invalide optie -- ‘%c’\n”
the \r\n note should apply here as well

nl_NL.po.zip

@andy5995
Copy link
Contributor Author

Thanks for another translation, @sexybiggetje ! I think it would be good to submit your po file as a PR after this is merged.

s for the suggestions about the strings in the source, they sound pretty reasonable to me. We'll take a look at that in the near future.

@shnupta shnupta merged commit 84e8e03 into shnupta:development Aug 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants