forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request CleverRaven#64926 from jbytheway/language-stats
Add percentage-translated statistic to language selection
- Loading branch information
Showing
10 changed files
with
188 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ ! -d lang/po ] | ||
then | ||
if [ -d ../lang/po ] | ||
then | ||
cd .. | ||
else | ||
echo "Error: Could not find lang/po subdirectory." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
for f in lang/po/*.po | ||
do | ||
n=`basename ${f} .po` | ||
o="lang/po/${n}.po" | ||
echo "getting stats for ${n}" | ||
num_translated=$( \ | ||
msgattrib --translated "${o}" 2>/dev/null | grep -c '^msgid') | ||
num_untranslated=$( \ | ||
msgattrib --untranslated "${o}" 2>/dev/null | grep -c '^msgid') | ||
mkdir -p lang/stats | ||
printf '{"%s"sv, %d, %d},\n' \ | ||
"${n}" "$((num_translated-1))" "$((num_untranslated-1))" \ | ||
> lang/stats/${n} | ||
done | ||
|
||
cat lang/stats/* > src/lang_stats.inc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <initializer_list> | ||
#include <lang_stats.h> | ||
|
||
using namespace std::literals::string_view_literals; | ||
|
||
static constexpr std::initializer_list<lang_stats> all_lang_stats = { | ||
#include <lang_stats.inc> | ||
}; | ||
|
||
const lang_stats *lang_stats_for( std::string_view lang ) | ||
{ | ||
for( const lang_stats &l : all_lang_stats ) { | ||
if( l.name == lang ) { | ||
return &l; | ||
} | ||
} | ||
|
||
return nullptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef CATA_SRC_LANG_STATS_H | ||
#define CATA_SRC_LANG_STATS_H | ||
|
||
#include <string_view> | ||
|
||
struct lang_stats { | ||
std::string_view name; | ||
int num_translated; | ||
int num_untranslated; | ||
|
||
float percent_translated() const { | ||
return 100.0 * num_translated / ( num_translated + num_untranslated ); | ||
} | ||
}; | ||
|
||
const lang_stats *lang_stats_for( std::string_view lang ); | ||
|
||
#endif // CATA_SRC_LANG_STATS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{"ar"sv, 5, 85479}, | ||
{"cs"sv, 2558, 82926}, | ||
{"da"sv, 230, 85254}, | ||
{"de"sv, 30775, 54709}, | ||
{"el"sv, 336, 85148}, | ||
{"es_AR"sv, 70464, 15020}, | ||
{"es_ES"sv, 75721, 9763}, | ||
{"fil_PH"sv, 45, 85439}, | ||
{"fr"sv, 43094, 42390}, | ||
{"ga_IE"sv, 4, 85480}, | ||
{"hu"sv, 21727, 63757}, | ||
{"id"sv, 647, 84837}, | ||
{"is"sv, 292, 85192}, | ||
{"it_IT"sv, 17861, 67623}, | ||
{"ja"sv, 82685, 2799}, | ||
{"ko"sv, 45566, 39918}, | ||
{"nb"sv, 3817, 81667}, | ||
{"nl"sv, 1162, 84322}, | ||
{"pl"sv, 68898, 16586}, | ||
{"pt_BR"sv, 29182, 56302}, | ||
{"ro"sv, 419, 85065}, | ||
{"ru"sv, 74906, 10578}, | ||
{"sr"sv, 175, 85309}, | ||
{"tr"sv, 471, 85013}, | ||
{"uk_UA"sv, 6708, 78776}, | ||
{"zh_CN"sv, 81014, 4470}, | ||
{"zh_TW"sv, 52200, 33284}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters