widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #11324
Re: [Merge] lp:~widelands-dev/widelands/translation_stats into lp:widelands
more comments inline.
Diff comments:
>
> === modified file 'src/ui_fsmenu/options.cc'
> --- src/ui_fsmenu/options.cc 2017-09-11 16:59:41 +0000
> +++ src/ui_fsmenu/options.cc 2017-10-14 16:12:18 +0000
> @@ -432,7 +421,7 @@
> language_dropdown_.add(_("Try system language"), "", nullptr, current_locale == "");
> language_dropdown_.add("English", "en", nullptr, current_locale == "en");
>
> - // Add translation directories to the list
> + // Add translation directories to the list. We use a vector so we can call std::sort on it.
My question is why we are not using a std::map then - it is always sorted and does not require std::sort.
> std::vector<LanguageEntry> entries;
> std::string selected_locale;
>
> @@ -484,6 +475,67 @@
> }
> }
>
> +/**
> + * Updates the language statistics message according to the currently selected locale.
> + * @param include_system_lang We only want to include the system lang if it matches the Widelands
> + * locale.
> + */
> +void FullscreenMenuOptions::update_language_stats(bool include_system_lang) {
> + int percent = 100;
> + std::string message = "";
> + if (language_dropdown_.has_selection()) {
> + std::string locale = language_dropdown_.get_selected();
> + // Empty locale means try system locale
> + if (locale.empty() && include_system_lang) {
> + std::vector<std::string> parts;
> + boost::split(parts, i18n::get_locale(), boost::is_any_of("."));
> + if (language_entries_.count(parts[0]) == 1) {
> + locale = parts[0];
> + } else {
> + boost::split(parts, parts[0], boost::is_any_of("@"));
> + if (language_entries_.count(parts[0]) == 1) {
> + locale = parts[0];
> + } else {
> + boost::split(parts, parts[0], boost::is_any_of("_"));
> + if (language_entries_.count(parts[0]) == 1) {
> + locale = parts[0];
> + }
> + }
> + }
> + }
> +
> + // If we have the locale, grab the stats and set the message
> + if (language_entries_.count(locale) == 1) {
> + try {
> + const LanguageEntry& entry = language_entries_[locale];
> + Profile prof("i18n/translation_stats.conf");
> + Section& s = prof.get_safe_section(locale);
> + percent = floor(100.f * s.get_int("translated") / s.get_int("total"));
> + if (percent == 100) {
> + message = (boost::format(_("The translation into %s is complete.")) %
> + entry.descname)
> + .str();
> + } else {
> + message = (boost::format(_("The translation into %s is %d%% complete.")) %
> + entry.descname % percent)
> + .str();
> + }
> + } catch (...) {
> + }
> + }
> + }
> +
> + // We will want some help with incomplete translations
> + if (percent <= 90) {
I am fine with 90, just add a comment for the rationale here.
> + message = message + " " +
> + (boost::format(_("If you wish to help us translate, please visit %s")) %
> + "<font underline=1>widelands.org/wiki/TranslatingWidelands</font>")
> + .str();
> + }
> + // Make font a bit smaller so the link will fit at 800x600 resolution.
> + translation_info_.set_text(as_uifont(message, 12));
> +}
> +
> void FullscreenMenuOptions::clicked_apply() {
> end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kApplyOptions);
> }
--
https://code.launchpad.net/~widelands-dev/widelands/translation_stats/+merge/332029
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/translation_stats.
References