Current File : //scripts/locale_import
#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/locale_import                   Copyright 2022 cPanel, L.L.C.
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use strict;

use Getopt::Param              ();
use Cpanel::Locale::Utils::XML ();

my $prm = Getopt::Param->new(
    {
        'no_args_help' => 1,
        'help_coderef' => sub {
            print <<"END_USAGE";
$0 [--locale={locale_tag} [--locale=… --locale=… …]] [--import={path} [--import=… --import=… …]] [--quiet] [--no-rebuild]

Import locales in XML format into the Locale database.

Options:
  --help                Show this help screen
  --quiet               Show less output than normal.
  --locale={locale_tag} Specify a locale to import. You can pass the flag multiple times in order to import multiple locales.
      This works on files in paths that `/usr/local/cpanel/scripts/locale_export --locale={locale_tag}` created.
  --import={file}       Specify the path to an XML file that is importable. You can pass the flag multiple times in order to import multiple files.
      This uses files in any arbitrary location and name.
  --no-rebuild          Do not rebuild the locale database after importing the XML file(s).
  --type={import_type}  Specify the import type as "xml" or "xlf" rather than guessing based on the file extension.

You must specify at least one --locale or --import flag.

The XML files that this script works with are created via /usr/local/cpanel/scripts/locale_export.

If nothing was imported the script will exit with an error status. To examine the reasons nothing was imported do not use --quiet.
END_USAGE
            exit;
        },
    }
);

my $overwrite_keys = $prm->get_param('overwrite-keys') ? 1 : 0;

my $verbose = $prm->get_param('quiet') ? 0 : 1;

my $type = $prm->get_param('type') || '';

my @files;

for my $loc ( $prm->get_param('locale') ) {
    if ( -e "/var/cpanel/locale/export/$loc.xlf" ) {
        push @files, "/var/cpanel/locale/export/$loc.xlf";
    }
    elsif ( -e "/var/cpanel/locale/export/$loc.xml" ) {
        push @files, "/var/cpanel/locale/export/$loc.xml";
    }
    else {
        print "Could not import “$loc” locale because it does not have an export file.\n" if $verbose;
    }
}
my $euid_home;
for my $file ( $prm->get_param('import') ) {

    # expand ~/ that was treated as a string and not expanded by the shell before being put in @ARGV
    if ( substr( $file, 0, 2 ) eq '~/' ) {
        $euid_home ||= ( getpwuid($>) )[7];    # only look it up if needed, and only look it up one time
        substr( $file, 0, 2, "$euid_home/" );
    }

    if ( -e $file ) {
        push @files, $file;
    }
    else {
        print "Could not import “$file” because that file does not exist.\n" if $verbose;
    }
}

if (@files) {
    my @recompile_flags;

    for my $file (@files) {
        my $error = '';
        print "Importing “$file” …\n" if $verbose;
        my $locale_tag;
        if ( $type eq 'xml' ) {
            $locale_tag = Cpanel::Locale::Utils::XML::xml_file_to_locale( $file, \$error );
        }
        elsif ( $type eq 'xlf' ) {
            $locale_tag = Cpanel::Locale::Utils::XML::xlf_file_to_locale( $file, \$error );
        }
        else {
            $locale_tag = Cpanel::Locale::Utils::XML::xml_to_locale( $file, \$error );
        }

        if ($locale_tag) {
            push @recompile_flags, "--locale=$locale_tag";
        }
        else {
            $error ||= 'An unknown error has occurred.';
            print "\tError: $error\n" if $verbose;
            next;
        }
    }

    if (@recompile_flags) {
        if ( $prm->get_param('no-rebuild') ) {
            print "Skipping database rebuild.\n" if $verbose;
        }
        else {

            # We do @recompile_flags as an array and then join it here so we could
            # easily switch to array context system() and/or saferun() based call
            my $cmd = join( ' ', '/usr/local/cpanel/bin/build_locale_databases', @recompile_flags );
            system( $verbose ? $cmd : "$cmd > /dev/null" );
        }
    }
    else {
        print "None of the files were importable\n";
        exit(1);
    }
}
else {
    print "No files to import\n" if $verbose;
    exit 1;
}
Seguro Celular
Home business sonyw300 6 de febrero de 2020
SEGURO PARA CUALQUIER MOMENTO
Evita cualquier situación con nuestro seguro para celular.

Contar con un seguro para celular te brinda una protección integral contra situaciones comunes como robo, accidentes y pérdida. No solo te ahorrará dinero en reparaciones o reemplazos, sino que también te proporcionará la tranquilidad de saber que estás respaldado en caso de cualquier eventualidad. Es una inversión inteligente para salvaguardar tu dispositivo, tus datos y tu tranquilidad.

De viaje
Protegido siempre ante cualquier imprevisto
Contratar ahora!
Robo
Asegura tu equipo ante un posible robo
Contratar ahora!
Accidentes
No pases un mal momento, protege tu dispositivo
Contratar ahora!
Previous slide
Next slide
¿Porqué seguro celular es para ti?
Nos comprometemos en brindarte la mejor protección para tu dispositivo
Cobertura mundial

Sea cual sea el problema estamos aquí para proteger tu inversión y brindarte la tranquilidad que necesitas.

Proceso de reclamación fácil y rápido

Sabemos que necesitas una solución rápida en caso de cualquier incidente.

Opciones personalizadas:

Ofrecemos opciones flexibles que se adaptan a tus requisitos individuales.

Atención al cliente excepcional

Estamos disponible para responder y brindarte asistencia personalizada en todo momento.

Tu tranquilidad está a
solo un clic de distancia

Protege tu dispositivo de cualquier imprevisto
TESTIMONIOS
¿Qué dicen nuestros
valiosos clientes?
"¡Increíble servicio de seguro para celular! Rápido, eficiente y confiable. Mi reclamo fue procesado sin problemas y recibí un reemplazo de mi teléfono en tiempo récord. ¡Gracias por brindar una excelente protección para mis dispositivos!"
male1085054890319
Herman Miller
"Me encanta la tranquilidad que me brinda su servicio de seguro para celular. Sé que mi dispositivo está protegido contra cualquier daño accidental o robo. Además, el proceso de reclamación es sencillo. Super recomendado!
female1021755931884
Sofia Millan
"Me ha salvado en más de una ocasión. El personal siempre está dispuesto a ayudar y resolver cualquier problema que surja. Gracias a su servicio, puedo disfrutar de mi teléfono sin preocupaciones.
male20131085934506012
Alexander Rodriguez