#!/usr/bin/perl # Copyright (C) 2017 Mageia # # This program 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; either version 2, or (at your option) # any later version. # # This program 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 this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # SYNOPSIS # # This program generates a PO file containing translations of the grub2 # runtime messages into the language specified by the first command line # argument. grub2 must be installed on the build system, so that the # translations are available. # # The full set of translations is quite large, so we only generate # translations for the messages we expect to see in the ISO bootloader. # # The PO file (${LANGUAGE}-grub.po) is stored in the current working # directory. use lib qw(/usr/lib/libDrakX); use strict; use Cwd qw(abs_path getcwd); use MDK::Common; use common; # Get correct namespace (grub instead of libDrakX). BEGIN { unshift @::textdomains, 'grub' } # Set the translation language. @ARGV == 1 && $ARGV[0] or die "Usage: make-grub-po \n"; $ENV{LANGUAGE} = $ARGV[0]; # Define the list of strings we want to translate. my @msgids = ( "Press enter to boot the selected OS, `e' to edit the commands before booting " . "or `c' for a command-line. ESC to return previous menu.", "The highlighted entry will be executed automatically in %ds.", "%ds remaining.", "%ds", "Minimal BASH-like line editing is supported. For the first word, TAB lists " . "possible command completions. Anywhere else TAB lists possible device or " . "file completions. %s", "ESC at any time exits.", "Press any key to continue...", "Possible commands are:", "Possible devices are:", "Possible files are:", "Possible partitions are:", "Possible arguments are:", "Possible things are:", "can't find command `%s'", "one argument expected", "two arguments expected", "three arguments expected", "four arguments expected", "missing arguments", "unknown argument", "missing `%c' symbol", "filename expected", "file or layout name required", "file `%s' not found", "no terminal specified", "terminal `%s' isn't found", "Active input terminals:", "Available input terminals:", "Active output terminals:", "Available output terminals:", "no server is specified", "Device %s:", "Partition %s:", "No known filesystem detected", "Filesystem cannot be accessed", "Filesystem type %s", "- Label `%s'", "- Last modification time %d-%02d-%02d %02d:%02d:%02d %s", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", " - Sector size %uB", " - Total size %llu%sKiB", " - Total size unknown", "Loaded fonts:", "error: %s.\n", ".5" ); # Open the output file my $fn = getcwd() . '/' . $ARGV[0] . '-grub.po'; open(my $fh, '>' . $fn) or die "couldn't open $fn"; print $fh "# This file is automatically generated\n"; print $fh "\n"; foreach (@msgids) { my ($msgid) = $_; my $msgstr = translate($msgid); # Blank the message string if there is no translation available. $msgstr = '' if $msgstr eq $msgid; # Any double quote characters need to be escaped when writing the # PO file. $msgid =~ s/"/\\"/g; $msgstr =~ s/"/\\"/g; # Any newline characters need to be escaped when writing the # PO file. $msgid =~ s/\R/\\n/g; $msgstr =~ s/\R/\\n/g; # Write the entry for this item. print $fh "msgid \"$msgid\"\n"; print $fh "msgstr \"$msgstr\"\n"; print $fh "\n"; } close($fh);