(svn r27887) -Cleanup: Remove unused/unimplemented prototype (adf88)
[openttd.git] / media / baseset / translations.awk
blobf15cb43ffe27a24aba10c089f0099f00d280380c
1 # $Id: openttd.desktop.translation.awk 24100 2012-04-08 14:29:31Z rubidium $
3 # This file is part of OpenTTD.
4 # 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.
5 # 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.
6 # 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/>.
9 # Awk script to extract translations for baseset descriptions
10 # from lang files for insertion into .obg/obs/obm files.
11 # If there is no translation, there is no output.
13 # The input file is scanned for the pattern
14 # !! <ini-key> <STR_id>
16 # The lang files (passed as variable 'langfiles') are scanned for <STR_id> and
17 # the translations are added to the output file:
18 # <ini-key>.<iso-code> = <translation>
21 # Simple insertion sort since not all AWKs have a sort implementation
22 function isort(A) {
23 n = 0
24 for (val in A) {
25 n++;
28 for (i = 2; i <= n; i++) {
29 j = i;
30 hold = A[j]
31 while (A[j - 1] > hold) {
32 j--;
33 A[j + 1] = A[j]
35 A[j] = hold
38 return n
41 /^!!/ {
42 ini_key = $2;
43 str_id = $3;
45 file = langfiles
46 while ((getline < file) > 0) {
47 if (match($0, "##isocode") > 0) {
48 lang = $2;
49 } else if (match($0, "^" str_id " *:") > 0) {
50 sub("^[^:]*:", "", $0)
51 i++;
52 if (lang == "en_GB") {
53 texts[i] = ini_key " = "$0;
54 } else {
55 texts[i] = ini_key "." lang " = "$0;
59 close(file);
61 count = isort(texts);
62 for (i = 1; i <= count; i++) {
63 print texts[i]
66 next
69 { print }