aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CatDap
Commit message (Collapse)AuthorAgeFilesLines
* Update Finnish translation from TxHEADmasterYuri Chornoivan2023-05-041-0/+511
|
* Adopt config to the new tx CLIYuri Chornoivan2023-05-041-1/+1
|
* Update Greek translation from TxYuri Chornoivan2022-08-041-4/+4
|
* Update Esperanto translation from TxYuri Chornoivan2022-07-211-98/+115
|
* Update Dutch translation from TxYuri Chornoivan2021-07-141-3/+3
|
* Update Dutch translation from TxYuri Chornoivan2021-06-301-37/+38
|
* Update Hebrew translation from TxYuri Chornoivan2021-04-021-8/+8
|
* Update Hebrew translation from TxYuri Chornoivan2021-03-211-2/+2
|
* Update Hebrew translation from TxYuri Chornoivan2021-03-191-5/+5
|
* Update Hebrew translation from TxYuri Chornoivan2021-02-281-5/+5
|
* Update Hebrew translation from TxYuri Chornoivan2021-02-051-7/+7
|
* Update Hebrew translation from TxYuri Chornoivan2020-12-281-6/+6
|
* Update Hebrew translation from TxYuri Chornoivan2020-12-021-2/+2
|
* Update Hebrew translation from TxYuri Chornoivan2020-11-301-4/+5
|
* Update Hebrew translation from TxYuri Chornoivan2020-11-151-16/+16
|
* Update Asturian translation from TxYuri Chornoivan2020-11-011-4/+4
|
* Update Asturian translationYuri Chornoivan2020-11-011-2/+2
|
* Update Asturian translation from TxYuri Chornoivan2020-10-311-3/+4
|
* Update Hebrew translation from TxYuri Chornoivan2020-10-191-16/+24
|
* Update Hebrew translation from TxYuri Chornoivan2020-09-221-2/+3
|
* Update Hindi translation from TxYuri Chornoivan2020-09-191-4/+4
|
* Update Hebrew translation from TxYuri Chornoivan2020-09-191-4/+4
|
* Update Spanish translation from TxYuri Chornoivan2020-06-111-7/+7
|
* Update Serbian translation from TxYuri Chornoivan2019-07-021-90/+108
|
* Update Tajik translation from TxYuri Chornoivan2019-07-011-7/+4
|
* Update Latvian translation from TxYuri Chornoivan2019-07-011-6/+3
|
* Update Breton translation from TxYuri Chornoivan2019-07-011-0/+495
|
* Update Tamil translation from TxYuri Chornoivan2019-07-011-0/+491
|
* Update Lithuanian translation from TxYuri Chornoivan2019-06-291-9/+7
|
* Update Hebrew translation from TxYuri Chornoivan2019-06-291-0/+492
|
* Update Polish translation from TxYuri Chornoivan2019-06-291-15/+7
|
* Update Azerbaijani translation from TxYuri Chornoivan2019-06-291-0/+491
|
* Update Asturian translation from TxYuri Chornoivan2019-06-291-0/+494
|
* Update Arabic translation from TxYuri Chornoivan2019-06-291-0/+492
|
* Update Serbian translation from TxYuri Chornoivan2019-06-291-9/+6
|
* Update Afrikaans translation from TxYuri Chornoivan2019-06-291-54/+14
|
* Update Czech translation from TxYuri Chornoivan2019-04-101-4/+6
|
* Update Albanian translation from TxYuri Chornoivan2019-03-111-21/+23
|
* Update Greek translation from TxYuri Chornoivan2019-01-061-4/+14
|
* Update Greek translation from TxYuri Chornoivan2018-12-221-20/+13
|
* Update Portuguese translation from TxYuri Chornoivan2018-11-211-39/+32
|
* Update German translationYuri Chornoivan2018-11-121-6/+6
|
* Update Bulgarian translation from TxYuri Chornoivan2018-09-071-0/+492
|
* Update Hindi translation from TxYuri Chornoivan2018-05-181-0/+492
|
* Update Estonian translation from TxYuri Chornoivan2018-05-141-2/+2
|
* Update Estonian translation from TxYuri Chornoivan2018-05-131-20/+26
|
* Update Japanese translation from TxYuri Chornoivan2018-02-251-3/+3
|
* Update Dutch translation from TxYuri Chornoivan2018-02-221-2/+9
|
* Update Brazilian Portuguese translation from TxYuri Chornoivan2018-02-201-6/+8
|
* Update French translation from TxYuri Chornoivan2018-01-131-7/+23
|
n class="hl kwa">if (!$switch{'charset'} && !$switch{'guess'}); if (exists $switch{'charset'}) { $switch{'charset'} = resolve_alias($switch{'charset'}) || die "'$switch{charset}' is not a valid charset."; } if ($switch{'guess'}) { # Encode::Detect::Detector doesn't seem to return a true value. # So we have to check if we can run detect. if (!eval { require Encode::Detect::Detector }) { my $root = ROOT_USER; print STDERR <<EOT; Using --guess requires that Encode::Detect be installed. To install Encode::Detect, first download it from: http://search.cpan.org/dist/Encode-Detect/ Then, unpack it into its own directory and run the following commands in that directory, as $root: ./Build.PL ./Build ./Build install EOT exit; } import Encode::Detect::Detector qw(detect); } my %overrides; if (exists $switch{'overrides'}) { my $file = new IO::File($switch{'overrides'}, 'r') || die "$switch{overrides}: $!"; my @lines = $file->getlines(); $file->close(); foreach my $line (@lines) { chomp($line); my ($digest, $encoding) = split(' ', $line); $overrides{$digest} = $encoding; } } my $dbh = Bugzilla->dbh; if ($dbh->isa('Bugzilla::DB::Mysql')) { # Get the actual current encoding of the DB. my $collation_data = $dbh->selectrow_arrayref( "SHOW VARIABLES LIKE 'character_set_database'"); my $db_charset = $collation_data->[1]; # Set our connection encoding to *that* encoding, so that MySQL # correctly accepts our changes. $dbh->do("SET NAMES $db_charset"); # Make the database give us raw bytes. $dbh->do('SET character_set_results = NULL') } $dbh->begin_work; foreach my $table ($dbh->bz_table_list_real) { my @columns = $dbh->bz_table_columns($table); my $pk = SPECIAL_KEYS->{$table}; if ($pk) { # Assure that we're on a version of Bugzilla where those keys # actually exist. foreach my $column (split ',', $pk) { $pk = undef if !$dbh->bz_column_info($table, $column); } } # Figure out the primary key. foreach my $column (@columns) { my $def = $dbh->bz_column_info($table, $column); $pk = $column if $def->{PRIMARYKEY}; } # If there's no PK, it's defined by a UNIQUE index. if (!$pk) { foreach my $column (@columns) { my $index = $dbh->bz_index_info($table, "${table}_${column}_idx"); if ($index && ref($index) eq 'HASH') { $pk = join(',', @{$index->{FIELDS}}) if $index->{TYPE} eq 'UNIQUE'; } } } foreach my $column (@columns) { my $def = $dbh->bz_column_info($table, $column); # If this is a text column, it may need work. if ($def->{TYPE} =~ /text|char/i) { # If there's still no PK, we're upgrading from 2.14 or earlier. # We can't reliably determine the PK (or at least, I don't want to # maintain code to record what the PK was at all points in history). # So instead we just use the field itself. $pk = $column if !$pk; print "Converting $table.$column...\n"; my $sth = $dbh->prepare("SELECT $column, $pk FROM $table WHERE $column IS NOT NULL AND $column != ''"); my @pk_array = map {"$_ = ?"} split(',', $pk); my $pk_where = join(' AND ', @pk_array); my $update_sth = $dbh->prepare( "UPDATE $table SET $column = ? WHERE $pk_where"); $sth->execute(); while (my @result = $sth->fetchrow_array) { my $data = shift @result; my $digest = md5_base64($data); my @primary_keys = reverse split(',', $pk); # We copy the array so that we can pop things from it without # affecting the original. my @pk_data = @result; my $pk_line = join (', ', map { "$_ = " . pop @pk_data } @primary_keys); my $encoding; if ($switch{'guess'}) { $encoding = do_guess($data); # We only show failures if they don't appear to be # ASCII. if ($switch{'show-failures'} && !$encoding && !is_valid_utf8($data)) { my $truncated = trunc($data); print "Row: [$pk_line]\n", "Failed to guess: Key: $digest", " DATA: $truncated\n"; } # If we fail a guess, and the data is valid UTF-8, # just assume we failed because it's UTF-8. next if is_valid_utf8($data); } # If we couldn't detect the charset (or were instructed # not to try), we fall back to --charset. If there's no # fallback, we just do nothing. if (!$encoding && $switch{'charset'}) { $encoding = $switch{'charset'}; } $encoding = $overrides{$digest} if $overrides{$digest}; # We only fix it if it's not ASCII or UTF-8 already. if ($encoding && !grep($_ eq $encoding, IGNORE_ENCODINGS)) { my $decoded = encode('utf8', decode($encoding, $data)); if ($switch{'dry-run'} && $data ne $decoded) { print "Row: [$pk_line]\n", "From: [" . trunc($data) . "] Key: $digest\n", "To: [" . trunc($decoded) . "]", " Encoding : $encoding\n"; } else { $update_sth->execute($decoded, @result); } } } # while (my @result = $sth->fetchrow_array) } # if ($column->{TYPE} =~ /text|char/i) } # foreach my $column (@columns) } $dbh->commit; __END__ =head1 NAME recode.pl - Converts a database from one encoding (or multiple encodings) to UTF-8. =head1 SYNOPSIS contrib/recode.pl [--guess [--show-failures]] [--charset=iso-8859-2] [--overrides=file_name] --dry-run Don't modify the database. --charset Primary charset your data is currently in. This can be optionally omitted if you do --guess. --guess Try to guess the charset of the data. --show-failures If we fail to guess, show where we failed. --overrides Specify a file containing overrides. See --help for more info. --help Display detailed help. If you aren't sure what to do, try: contrib/recode.pl --guess --charset=cp1252 =head1 OPTIONS =over =item --dry-run Don't modify the database, just print out what the conversions will be. recode.pl will print out a Key for each item. You can use this in the overrides file, described below. =item --guess If your database is in multiple different encodings, specify this switch and recode.pl will do its best to determine the original charset of the data. The detection is usually very reliable. If recode.pl cannot guess the charset, it will leave the data alone, unless you've specified --charset. =item --charset=charset-name If you do not specify --guess, then your database is converted from this character set into the UTF-8. If you have specified --guess, recode.pl will use this charset as a fallback--when it cannot guess the charset of a particular piece of data, it will guess that the data is in this charset and convert it from this charset to UTF-8. charset-name must be a charset that is known to perl's Encode module. To see a list of available charsets, do: C<perl -MEncode -e 'print join("\n", Encode-E<gt>encodings(":all"))'> =item --show-failures If --guess fails to guess a charset, print out the data it failed on. =item --overrides=file_name This is a way of specifying certain encodings to override the encodings of --guess. The file is a series of lines. The line should start with the Key from --dry-run, and then a space, and then the encoding you'd like to use. =back