Server IP : 103.119.228.120 / Your IP : 3.144.21.206 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /scripts/ |
Upload File : |
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - scripts/locale_export 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 warnings; use Getopt::Param (); use Cpanel::Locale (); use Cpanel::Locale::Utils::Display (); use Cpanel::Locale::Utils::XML (); use Cpanel::SafeDir::MK (); my $prm = Getopt::Param->new( { 'no_args_help' => 1, 'help_coderef' => sub { print <<"END_USAGE"; $0 --locale={locale_tag} [--locale=… --locale=… …] [--quiet] [--export-{locale_tag}={path}] [--dumper-format] [--exclude-bracketed-strings] [--no-fallback] Export locales from the Locale database in XML format. Options: --help Show this help screen --quiet Show less output than normal. --locale={locale_tag} Specify a locale to export. You may pass the flag multiple times in order to export multiple locales. This creates files in a default location that `/usr/local/cpanel/scripts/locale_import --locale={locale_tag}` knows to use. --export-{locale_tag}={file} Save the export of the locale {locale_tag} to {file} instead of the standard place. This creates files that can be imported with `/usr/local/cpanel/scripts/locale_import --import={file}` --dumper-format Export into the old format instead of XLIFF (will force an .xml extension on any --export-XX paths) --recover Try to recover on encountering an ill-formed phrase. --exclude-bracketed-strings Exclude strings that contain bracket notion, which may cause problem on some translation platforms. --no-fallback Do not use orginial strings as fallback if no translation is available, leave target blank. The XML files that this script creates can be imported via /usr/local/cpanel/scripts/locale_import If there were problems exporting the script will exit with an error status. To examine the details of what happened do not use --quiet. END_USAGE exit; }, } ); my $verbose = $prm->get_param('quiet') ? 0 : 1; my $options = { 'recover' => ( $prm->get_param('recover') ? 1 : 0 ), 'no-brackets' => ( $prm->get_param('exclude-bracketed-strings') ? 1 : 0 ), 'no-fallback' => ( $prm->get_param('no-fallback') ? 1 : 0 ), }; my $count = 0; my $failed = 0; my $locale = Cpanel::Locale->get_handle(); my %locale_lookup; @locale_lookup{ Cpanel::Locale::Utils::Display::get_locale_list($locale) } = (); my $euid_home; foreach my $loc ( $prm->get_param('locale') ) { $count++; if ( !exists $locale_lookup{$loc} ) { print "Invalid locale\n" if $verbose; $failed++; next; } my $path = $prm->get_param('dumper-format') ? "/var/cpanel/locale/export/$loc.xml" : "/var/cpanel/locale/export/$loc.xlf"; if ( $prm->get_param("export-$loc") ) { $path = $prm->get_param("export-$loc"); $path =~ s/\.[^.]+$//; # strip any existing extension … if ( $prm->get_param('dumper-format') ) { $path .= '.xml'; # … replace it w/ .xml } else { $path .= '.xlf'; # … replace it w/ .xlf } } # expand ~/ that was treated as a string and not expanded by the shell before being put in @ARGV if ( substr( $path, 0, 2 ) eq '~/' ) { $euid_home ||= ( getpwuid($>) )[7]; # only look it up if needed, and only look it up one time substr( $path, 0, 2, "$euid_home/" ); } my ( $head, @dir ) = reverse( split( /\//, $path ) ); my $dir = join( '/', reverse(@dir) ); if ( $dir && !-d $dir ) { if ( !Cpanel::SafeDir::MK::safemkdir($dir) ) { print "Could not create path '$dir': $!\n" if $verbose; $failed++; next; } } if ( -e $path ) { print "Replacing existing export file '$path'\n" if $verbose; unlink($path); if ( -e $path ) { print "Could not unlink '$path': $!\n" if $verbose; $failed++; next; } } my $error = ''; if ( Cpanel::Locale::Utils::XML::locale_to_xml( $path, $loc, \$error, $options ) ) { print "$error'$loc' has been exported to '$path'.\n" if $verbose; } else { print "Failed to create XML file for locale '$loc': $error\n" if $verbose; $failed++; next; } } if ( !$count || $failed ) { if ($verbose) { if ($failed) { print "$failed out of $count failed to export.\n"; } elsif ( !$count ) { print "No locales to export.\n"; } } exit 1; }