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 i18n support #311

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open

Add i18n support #311

wants to merge 44 commits into from

Conversation

smolBlackCat
Copy link

@smolBlackCat smolBlackCat commented Jun 13, 2024

This is still a work in Progress. Some testing still have to be made before opening for merging

  • Improve build settings
  • Test on Windows
  • Test on Linux
  • Add locale location resolution code

@smolBlackCat
Copy link
Author

Screenshot from 2024-06-13 10-49-12
Profile Dialog Window translated to Portuguese

smolBlackCat and others added 9 commits June 15, 2024 16:52
* Properly include <fmt/format.h>
* Format texts in abaddon.cpp
* Update abaddon.pot
* Update pt_BR.po
* Mark startup.cpp strings for translation
* Refactor chatinputindicator.cpp i18n
* Update POTFILES
* Update abaddon.pot
@smolBlackCat
Copy link
Author

Internationalisation code is also working on Windows. The build environment here is UCRT64, but it should also work well with MINGW64

image

There are still some strings that needs to be translated. Working on it

* Update abaddon.pot
* Update POTFILES
* Update Brazilian Portuguese Translation
@smolBlackCat smolBlackCat changed the title Add initial i18n support Add i18n support Jun 17, 2024
@smolBlackCat smolBlackCat marked this pull request as ready for review June 17, 2024 17:25
@smolBlackCat
Copy link
Author

The above commits implement internationalisation into Abaddon. This feature will allow users to utilise the application in their native language. It'll also allow contributors to translate the project into other available languages. This closes #308.

Behaviour

The approach used for internationalisation is using gettext to read translated strings of a .mo file, which is usually located at /usr/share/locale/ in Linux systems. The default behaviour for Windows and Mac systems is to load the locale folder from the current directory.

Changes in the project workflow

With this addition, code that has some kind of text being shown to the user will also have to consider i18n. The workflow is not complicated since most cumbersome parts (i.e updating and compiling translations) are done by CMake. Of course, some manual work is still needed, like adding the source file to POTFILES for fetching strings for translation and updating abaddon.pot file.

Workflow

  1. Add the source file containing strings to be translated in the POTFILES file
  2. Include the <glibmm/i18n.h> header in the source file containing the strings to be marked.
  3. Mark strings for translation using the macro "_" (e.g _("I'm going to be translated")). In some cases, string formatting is necessary in contexts where string concatenation is not enough.
  4. Update abaddon.pot file by issuing xgettext -f po/POTFILES -o po/abaddon.pot --keyword=_. To merge the changes in existing translation files, just run the build command on the build directory.

@ouwou
Copy link
Member

ouwou commented Jun 22, 2024

i like how this looks :^)
the two things that jump out to me though are
1: markup seems like something that shouldnt be included for translation
2: instead of fmt i think we should use Glib::ustring::compose. its what the docs suggest and probably is safer in case theres any scary utf-8 encoding stuff going on behind the scenes

@ouwou
Copy link
Member

ouwou commented Jun 22, 2024

docs say markup is "probably ok" apparently
image

as for the build errors
mac: i guess add this before the locale code its erroring on

#ifdef setlocale
#undef setlocale
#endif

linux looks like a package youll probably know

@smolBlackCat
Copy link
Author

Guys, Linux and Windows builds are working as expected. However. the MacOS build is failing because of a "reference not found" error. I kind of have some idea of what it can be, but I don't want to mess up the commit history with tests. Does anyone have an appropriate solution for this?

What I've found

@ouwou
Copy link
Member

ouwou commented Jun 30, 2024

if the fix is hacky so be it. if you wanna play around with CI runs without messing up commit history u can just do it on another branch and squash it in when it works

@smolBlackCat
Copy link
Author

Sorry for taking so long to respond, life stuff. Ok, I'll begin writing code for the Mac port. I will also add i18n code to the add-stage patches

@smolBlackCat smolBlackCat reopened this Jul 10, 2024
* Add i18n to the stages functionality
* Update the Brazilian Portuguese Translation
@smolBlackCat
Copy link
Author

smolBlackCat commented Jul 15, 2024

  • Fix MacOS incompatibility
  • Fix graphical artifacts in auditlogpane.cpp
  • Replace fmt::format calls

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.

5 participants