Skip to content

Commit

Permalink
Change: treat languages as finished, if translations are 75% completed.
Browse files Browse the repository at this point in the history
Unfinished translations are not auto-picked from the locale.
In release builds, unfinished translations are not offered in the GUI.
Unfinished translations are available in non-release builds, or by editing openttd.cfg.
  • Loading branch information
frosch123 committed Apr 16, 2021
1 parent 1ec4873 commit 924b0dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/language.h
Expand Up @@ -58,6 +58,7 @@ struct LanguagePackHeader {
char cases[MAX_NUM_CASES][CASE_GENDER_LEN]; ///< the cases used by this translation

bool IsValid() const;
bool IsReasonablyFinished() const;

/**
* Get the index for the given gender.
Expand Down
1 change: 1 addition & 0 deletions src/settings_gui.cpp
Expand Up @@ -218,6 +218,7 @@ struct GameOptionsWindow : Window {

case WID_GO_LANG_DROPDOWN: { // Setup interface language dropdown
for (uint i = 0; i < _languages.size(); i++) {
if (IsReleasedVersion() && !_languages[i].IsReasonablyFinished()) continue;
auto item = new DropDownListParamStringItem(IsReleasedVersion() || _languages[i].missing < _settings_client.gui.missing_strings_threshold ? STR_JUST_RAW_STRING : STR_GAME_OPTIONS_LANGUAGE_PERCENTAGE, i, false);
if (&_languages[i] == _current_language) {
*selected_index = i;
Expand Down
13 changes: 13 additions & 0 deletions src/strings.cpp
Expand Up @@ -1718,6 +1718,15 @@ bool LanguagePackHeader::IsValid() const
StrValid(this->digit_decimal_separator, lastof(this->digit_decimal_separator));
}

/**
* Check whether a translation is sufficiently finished
* to offer it to the public.
*/
bool LanguagePackHeader::IsReasonablyFinished() const
{
return 4 * this->missing < LANGUAGE_TOTAL_STRINGS;
}

/**
* Read a particular language.
* @param lang The metadata about the language.
Expand Down Expand Up @@ -1972,6 +1981,10 @@ void InitializeLanguagePacks()
}

if (strcmp (lng.isocode, "en_GB") == 0) en_GB_fallback = &lng;

/* Only auto-pick finished translations */
if (!lng.IsReasonablyFinished()) continue;

if (strncmp(lng.isocode, lang, 5) == 0) chosen_language = &lng;
if (strncmp(lng.isocode, lang, 2) == 0) language_fallback = &lng;
}
Expand Down

0 comments on commit 924b0dd

Please sign in to comment.