diff options
author | frosch <frosch@openttd.org> | 2013-04-24 20:30:02 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-04-24 20:30:02 +0000 |
commit | df63cb6cef01e3d2ac4b1e871b1556cea8a864c5 (patch) | |
tree | 0ca6f18cfdc1913e2a8f1ab12b7227a0ceb1cf1c /media/baseset/translations.awk | |
parent | f442cd7798d4dba902a11d8e09d34b5a8c5ef827 (diff) | |
download | openttd-df63cb6cef01e3d2ac4b1e871b1556cea8a864c5.tar.xz |
(svn r25205) -Feature: Translations of baseset descriptions via lang files.
Diffstat (limited to 'media/baseset/translations.awk')
-rw-r--r-- | media/baseset/translations.awk | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/media/baseset/translations.awk b/media/baseset/translations.awk new file mode 100644 index 000000000..3269d40b7 --- /dev/null +++ b/media/baseset/translations.awk @@ -0,0 +1,48 @@ +# $Id: openttd.desktop.translation.awk 24100 2012-04-08 14:29:31Z rubidium $ + +# This file is part of OpenTTD. +# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. +# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. + +# +# Awk script to extract translations for baseset descriptions +# from lang files for insertion into .obg/obs/obm files. +# If there is no translation, there is no output. +# +# The input file is scanned for the pattern +# !! <ini-key> <STR_id> +# +# The lang files (passed as variable 'langfiles') are scanned for <STR_id> and +# the translations are added to the output file: +# <ini-key>.<iso-code> = <translation> +# + +/^!!/ { + ini_key = $2; + str_id = $3; + + file = langfiles + while ((getline < file) > 0) { + if (match($0, "##isocode") > 0) { + lang = $2; + } else if (match($0, "^" str_id " *:") > 0) { + sub("^[^:]*:", "", $0) + if (lang == "en_GB") { + texts[""] = ini_key " = "$0; + } else { + texts[lang] = ini_key "." lang " = "$0; + } + } + } + close(file); + + count = asort(texts); + for (i = 1; i <= count; i++) { + print texts[i] + } + + next +} + +{ print } |