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

Implement translation support #533

Closed
wants to merge 23 commits into from
Closed

Implement translation support #533

wants to merge 23 commits into from

Conversation

AJenbo
Copy link
Member

@AJenbo AJenbo commented Jan 5, 2020

This brings translation support to the game, it will probably need a bit of adjustment on different platforms and for the handling of static texts. Currently, also only the strings from DiabloUI and appfat.cpp are marked as translatable.

Fixes #66

Skærmbillede fra 2020-01-07 23-02-49

SourceX/DiabloUI/fonts.cpp Outdated Show resolved Hide resolved
@AJenbo
Copy link
Member Author

AJenbo commented Jan 5, 2020

@glebm how do you feel about the way I'm handling the translation of static texts here? I saw it used in other projects, all strings are wrapped in a fake translation function (N_()) and the actual translation then happens when the texts are scheduled for rendering: 1acd179

@glebm
Copy link
Collaborator

glebm commented Jan 5, 2020

@AJenbo There is a danger with that approach when mixing N_ and _ calls, described here: https://www.gnu.org/software/gettext/manual/html_node/Special-cases.html

For UI components, perhaps we could mark it explicitly with a wrapper type:

struct UiStringView {
  constexpr UiStringView(const char *text, bool localize = false) 
    : localize_(localize), text_(text) {
  }

  const char *localized() const {
    if (localize_) return gettext(text_);
    return text_;
  }
  // (or make the fields public and move the logic to render/display code)

 private:
  bool localize_;
  const char *text_;
};

The macro would return this type and the static arrays would change from:

-const char *const CREDITS_LINES[] = {
+const UiStringView CREDITS_LINES[] = {

The type above is implicitly constructible from a C-string literal.

@glebm
Copy link
Collaborator

glebm commented Jan 5, 2020

E.g. like this: https://godbolt.org/z/4fnjQy

@AJenbo
Copy link
Member Author

AJenbo commented Feb 23, 2020

If any one can getting this building on Windows, Mac and Swtich I would appreciate the help.

@AJenbo AJenbo added the help wanted Extra attention is needed label Feb 23, 2020
@ghost
Copy link

ghost commented Apr 12, 2020

DeepCode's analysis on #2a5691 found:

⚠️ 1 warning

👉 View analysis in DeepCode’s Dashboard

☺️ If you want to provide feedback on our bot, here is how to contact us.

@AJenbo AJenbo mentioned this pull request May 3, 2020
@AJenbo
Copy link
Member Author

AJenbo commented May 3, 2020

Looks like https://github.com/SuperTux/supertux is a good example of how to get this implemented for Windows and Mac

translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved

#: SourceX/DiabloUI/selconn.cpp:41
msgid "no gateway needed"
msgstr "ingen gateway"
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
msgstr "ingen gateway"
msgstr "gateway behøves ikke"

(check if this fits first)

translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved
translations/da.po Outdated Show resolved Hide resolved
@AJenbo AJenbo closed this Apr 25, 2021
@AJenbo AJenbo deleted the translation branch April 27, 2021 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Translation support
5 participants