Enable updating po files via make and other stuff
Created by: daPhipz
Apologies - this is quite a big PR, but I think it is really worth it. So please hear me out xD
I recently contributed to the German translation of hidetopbar
. I found that the instructions on the README on how to get the latest strings from the source code were a bit lacking (e.g. how to merge the pot
file into the po
file), so I wanted to improve that in this PR.
All the commits with explanation
I will also provide further information directly as comments on the code in this PR where needed.
"Streamline string extraction"
While I was working on the documentation as wrote above, I discovered that all the translatable strings came from an "artificial" file, and not directly from the source code. This has one big disadvantage: If a translator wants to know something about the context in which a specific string will appear in the UI, it is hard to find this string in the code. Now, this is easier since there are references to the files and line numbers in the po
file.
These changes also remove the need for intltool
to be installed.
"Add some details to the po file"
This does some sed
magic to populate the pot
file header with information about this project.
po
files with the Makefile"
"Update This enables people to easily update the translation files whenever there is a change in translatable strings. You can either update all po
files at once (make all-po
) or just one single po
file (make ./locale/XX/LC_MESSAGES/hidetopbar.po
)
I am not that fluent in writing Makefiles - is there a way to shorten this last command to something like make XX
, where XX is the language code that is also the name of the folder in locale/XX
? If yes, you would save some typing...
*.po
backups to gitignore"
"Add Merging the pot
and the po
file leaves a *.po~
behind, which is a backup done before the merge. We don't need them be tracked by git, so I put them in gitignore.
"Update translation files"
This is the result of running make all-po
, to showcase what it does and to bring all translation to an up-to-date state.
OK now, that's it. Feel free to ask any questions you have about my PR - I will answer them as soon as I can. Thank you for your time!