CHips L MINI SHELL

CHips L pro

Current Path : /proc/2/root/usr/local/rvglobalsoft/rvsitebuilder7/auto/RVSInstaller/
Upload File :
Current File : //proc/2/root/usr/local/rvglobalsoft/rvsitebuilder7/auto/RVSInstaller/Language.pm

#!/usr/bin/perl
##LICENSE##

package RVSInstaller::Language;

use strict;
#use warnings;

use vars qw( $VERSION );

$VERSION = "0.01";

sub new{
    my $class = shift;
    my %raw_opt = @_;
    my $seft = { PARAM => \%raw_opt };
    bless($seft, $class);
    $seft->loadLang();

    return $seft;
}

sub loadLang {
    my $seft = shift;

    if ( -e $seft->{'PARAM'}->{'Path'} . '/' . $seft->{'PARAM'}->{'GlobalFile'} . '_' . $seft->{'PARAM'}->{'Language'} . '.' . $seft->{'PARAM'}->{'GlobalFileType'} ) {
        if(open(my $RH, '<', $seft->{'PARAM'}->{'Path'} . '/' . $seft->{'PARAM'}->{'GlobalFile'} . '_' . $seft->{'PARAM'}->{'Language'} . '.' . $seft->{'PARAM'}->{'GlobalFileType'})) {
            my $module = '';
            while (my $data = <$RH>) {
                $data=~s/\r|\n//gi;    
                if ( $data=~m/^;/i || $data eq '' ) {
                    next;
                }
                elsif ( /^\[(.*?)\]/i ) {
                    $data=~s/^\ //gi;
                    $data=~s/\ $//gi;
                    $module = $1;
                }
                else {
                    my ($langKey, $langValue) = split(/=/, $_, 2);
                    $langKey =~s/^\ //gi;
                    $langKey =~s/\ $//gi;
                    $langValue =~s/^\ //gi;
                    $langValue =~s/\ $//gi;
                    $langValue =~s/"//gi;
                    if ( $module eq '' ) {
                        $seft->{'LANG'}->{$langKey} = $langValue;
                    }
                    else {
                        $seft->{'LANG'}->{$module}->{$langKey} = $langValue;
                    }
                }
            }
            close($RH);
        }
    }
    if ( -e $seft->{'PARAM'}->{'Path'} . '/' . $seft->{'PARAM'}->{'LangFile'} . '_' . $seft->{'PARAM'}->{'Language'} . '.' . $seft->{'PARAM'}->{'LangFileType'} ) {
        if (open(my $RH, '<', $seft->{'PARAM'}->{'Path'} . '/' . $seft->{'PARAM'}->{'LangFile'} . '_' . $seft->{'PARAM'}->{'Language'} . '.' . $seft->{'PARAM'}->{'LangFileType'})) {
            my $module = '';
            while (my $data = <$RH>) {
                $data=~s/\r|\n//gi;    
                if ( $data=~m/^;/i || $data eq '') {
                    next;
                }
                elsif ( $data=~/^\[(.*?)\]/i ) {
                    $data=~s/^\ //gi;
                    $data=~s/\ $//gi;
                    $module = $1;
                }
                else {
                    my ($langKey, $langValue) = split(/=/, $data, 2);
                    $langKey =~s/^\ //gi;
                    $langKey =~s/\ $//gi;
                    $langValue =~s/^\ //gi;
                    $langValue =~s/\ $//gi;
                    $langValue =~s/"//gi;
                    if ( $module eq '' ) {
                        $seft->{'LANG'}->{$langKey} = $langValue;
                    }
                    else {
                        $seft->{'LANG'}->{$module}->{$langKey} = $langValue;
                    }
                }
            }
            close($RH);
        }
    }
}

sub TranSlate {
    my $seft = shift;
    my ($text) = shift;
    my (@variable) = @_;
    if ( exists $seft->{LANG}->{$text} ) {
        my ($meaning) = $seft->{LANG}->{$text};
        if ( @variable > 0) {
            my ($i);
            for ( $i =1; $i<= @variable; $i++) {
                $meaning =~s/\$$i/$variable[$i - 1]/gi;
            }
        }
        return $meaning;
    }
    else {
        return '> ' . $text . ' < ';    
    }
}
1;
__END__

Copyright 2K16 - 2K18 Indonesian Hacker Rulez