Internationalization: Translation Tables Update.
[openemr.git] / contrib / util / language_translations / lang_dump.plx
blob252dd3474c72051b6f46499270ed4090168648bb
1 #!/usr/bin/perl
2 use strict;
4 use DBI;
6 #######################################################################
7 # Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License
11 # as published by the Free Software Foundation; either version 2
12 # of the License, or (at your option) any later version.
14 # This dumps language constants and their translations for one
15 # specified language to standard output in tab-delimited format,
16 # suitable for input to the companion script lang_load.plx.
17 #######################################################################
19 #######################################################################
20 # Parameters that you should customize #
21 #######################################################################
23 my $DBNAME = "openemr"; # database name
25 # Get this language code from the lang_id column of the lang_languages
26 # table in the source database.
28 my $LANGCODE = 5; # desired language
30 # You can hard-code the database user name and password (see below),
31 # or else put them into the environment with bash commands like these
32 # before running this script:
34 # export DBI_USER=username
35 # export DBI_PASS=password
37 my $dbh = DBI->connect("dbi:mysql:dbname=$DBNAME") or die $DBI::errstr;
39 # my $dbh = DBI->connect("dbi:mysql:dbname=$DBNAME", "username", "password")
40 # or die $DBI::errstr;
42 #######################################################################
43 # Startup #
44 #######################################################################
46 $| = 1; # Turn on autoflushing of stdout.
48 #######################################################################
49 # Main Loop #
50 #######################################################################
52 my $sth = $dbh->prepare("select lc.constant_name, ld.definition " .
53 "from lang_constants as lc, lang_definitions as ld where " .
54 "ld.cons_id = lc.cons_id and ld.lang_id = $LANGCODE")
55 or die $dbh->errstr;
56 $sth->execute() or die $sth->errstr;
58 while (my @row = $sth->fetchrow_array()) {
59 my ($constant_name, $definition) = @row;
60 next if ($definition =~ /^\s*$/);
61 print "$constant_name\t$definition\n";
64 #######################################################################
65 # Shutdown #
66 #######################################################################
68 $dbh->disconnect;