From 06a5090bfcbc95f0ee65d138ac35c0b0dda51668 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 3 Nov 2009 12:13:24 -0800 Subject: Update translations from TranslateWiki scripts/update_translations.php now pulls updated files from TranslateWiki and merges them to an updated master. Note that the .po files exported from TranslateWiki do lose some of the old manual comments for now. --- scripts/update_translations.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'scripts/update_translations.php') diff --git a/scripts/update_translations.php b/scripts/update_translations.php index f145c1f0b..4f3ebb1a2 100755 --- a/scripts/update_translations.php +++ b/scripts/update_translations.php @@ -43,8 +43,16 @@ $languages = get_all_languages(); foreach ($languages as $language) { $code = $language['lang']; - $file_url = 'http://status.net/pootle/' . $code . - '/statusnet/LC_MESSAGES/statusnet.po'; + + // Fetch updates from TranslateWiki... + $twcode = str_replace('_', '-', strtolower($code)); // pt_BR -> pt-br + $file_url = 'http://translatewiki.net/w/i.php?' . + http_build_query(array( + 'title' => 'Special:Translate', + 'task' => 'export-to-file', + 'group' => 'out-statusnet', + 'language' => $twcode)); + $lcdir = INSTALLDIR . '/locale/' . $code; $msgdir = "$lcdir/LC_MESSAGES"; $pofile = "$msgdir/statusnet.po"; @@ -72,7 +80,8 @@ foreach ($languages as $language) { if (sha1($new_file) != $existingSHA1 || !file_exists($mofile)) { echo "Updating ".$code."\n"; file_put_contents($pofile, $new_file); - system(sprintf('msgmerge -U %s %s', $pofile, $statusnet_pot)); + // --backup=off is workaround for Mac OS X fail + system(sprintf('msgmerge -U --backup=off %s %s', $pofile, $statusnet_pot)); system(sprintf('msgfmt -f -o %s %s', $mofile, $pofile)); } else { echo "Unchanged - ".$code."\n"; -- cgit v1.2.3-54-g00ecf From 8beef3eab3db4e60da56cd5f535c3eae2f2f5283 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 6 Nov 2009 16:40:54 +0100 Subject: * add language code conversion for translatewiki.net where needed * skip update of code 'en' (as English is the source language) --- scripts/update_translations.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'scripts/update_translations.php') diff --git a/scripts/update_translations.php b/scripts/update_translations.php index 4f3ebb1a2..88780898d 100755 --- a/scripts/update_translations.php +++ b/scripts/update_translations.php @@ -39,12 +39,28 @@ set_time_limit(60); $languages = get_all_languages(); /* Update the languages */ +// Language code conversion for translatewiki.net +$codeMap = array( + 'nb' => 'no', + 'pt_BR' => 'pt-br', + 'zh_CN' => 'zh-hans', + 'zh_TW' => 'zh-hant' +); foreach ($languages as $language) { + $code = $language['lang']; - $code = $language['lang']; + // Skip export of source language + if( $language == 'en' ) { + continue; + } - // Fetch updates from TranslateWiki... + // Convert code if needed + if( isset( $codeMap[$code] ) ) { + $code = $codeMap[$code]; + } + + // Fetch updates from translatewiki.net... $twcode = str_replace('_', '-', strtolower($code)); // pt_BR -> pt-br $file_url = 'http://translatewiki.net/w/i.php?' . http_build_query(array( -- cgit v1.2.3-54-g00ecf From 814b513aa5d86a38e7b6db220d36fca253bdabfe Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 6 Nov 2009 16:53:07 +0100 Subject: Fix a few bugs I added in previous revision --- scripts/update_translations.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'scripts/update_translations.php') diff --git a/scripts/update_translations.php b/scripts/update_translations.php index 88780898d..88b85dc12 100755 --- a/scripts/update_translations.php +++ b/scripts/update_translations.php @@ -39,7 +39,7 @@ set_time_limit(60); $languages = get_all_languages(); /* Update the languages */ -// Language code conversion for translatewiki.net +// Language code conversion for translatewiki.net (these are MediaWiki codes) $codeMap = array( 'nb' => 'no', 'pt_BR' => 'pt-br', @@ -51,17 +51,19 @@ foreach ($languages as $language) { $code = $language['lang']; // Skip export of source language - if( $language == 'en' ) { + // and duplicates + if( $code == 'en' || $code = 'no' ) { continue; } // Convert code if needed if( isset( $codeMap[$code] ) ) { - $code = $codeMap[$code]; + $twnCode = $codeMap[$code]; + } else { + $twnCode = str_replace('_', '-', strtolower($code)); // pt_BR -> pt-br } // Fetch updates from translatewiki.net... - $twcode = str_replace('_', '-', strtolower($code)); // pt_BR -> pt-br $file_url = 'http://translatewiki.net/w/i.php?' . http_build_query(array( 'title' => 'Special:Translate', -- cgit v1.2.3-54-g00ecf From 023d5c17ab2abe6a221d6db54778d8d585b6dd86 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 6 Nov 2009 17:16:43 +0100 Subject: More bug fixes. --- scripts/update_translations.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/update_translations.php') diff --git a/scripts/update_translations.php b/scripts/update_translations.php index 88b85dc12..baa377cac 100755 --- a/scripts/update_translations.php +++ b/scripts/update_translations.php @@ -52,7 +52,7 @@ foreach ($languages as $language) { // Skip export of source language // and duplicates - if( $code == 'en' || $code = 'no' ) { + if( $code == 'en' || $code == 'no' ) { continue; } @@ -69,7 +69,7 @@ foreach ($languages as $language) { 'title' => 'Special:Translate', 'task' => 'export-to-file', 'group' => 'out-statusnet', - 'language' => $twcode)); + 'language' => $twnCode)); $lcdir = INSTALLDIR . '/locale/' . $code; $msgdir = "$lcdir/LC_MESSAGES"; -- cgit v1.2.3-54-g00ecf From f7b0017f219d649a3acb3d650cb6d4fbb79b9956 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Fri, 6 Nov 2009 18:49:42 +0100 Subject: Do not export codes twice --- scripts/update_translations.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'scripts/update_translations.php') diff --git a/scripts/update_translations.php b/scripts/update_translations.php index baa377cac..580c472ee 100755 --- a/scripts/update_translations.php +++ b/scripts/update_translations.php @@ -47,6 +47,8 @@ $codeMap = array( 'zh_TW' => 'zh-hant' ); +$doneCodes = array(); + foreach ($languages as $language) { $code = $language['lang']; @@ -56,6 +58,13 @@ foreach ($languages as $language) { continue; } + // Do not export codes twice (happens for 'nb') + if( in_array( $code, $doneCodes ) ) { + continue; + } else { + $doneCodes[] = $code; + } + // Convert code if needed if( isset( $codeMap[$code] ) ) { $twnCode = $codeMap[$code]; -- cgit v1.2.3-54-g00ecf