CMXX - Translations - updates
This commit is contained in:
@@ -2913,4 +2913,37 @@ function getRelativeTime($timestamp) {
|
||||
$years = floor($diff / $year);
|
||||
return $years.(($years != 1)?$time_years:$time_year) . " $suffix";
|
||||
}
|
||||
}
|
||||
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// Generate language files ++++++++++++++
|
||||
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
function generateLanguageFile($language_key,$token){
|
||||
|
||||
//GET TRANSLATION RECORDS
|
||||
$api_url = '/v2/translations/generatefile='.$language_key;
|
||||
$responses = ioAPIv2($api_url,'',$token);
|
||||
|
||||
if (!empty($responses)){
|
||||
//define translation variable
|
||||
$translation = '<?php'.PHP_EOL;
|
||||
|
||||
//decode the API response
|
||||
$responses = json_decode($responses,true);
|
||||
|
||||
//loop through translation records and create variables
|
||||
foreach ($responses as $response){
|
||||
//create variable_name = translation per item
|
||||
$translation .= '$'.$response['variable'].' = \''.$response['translation'].'\';'.PHP_EOL;
|
||||
}
|
||||
//ADD closure tag for PHP
|
||||
$translation .= '?>';
|
||||
//Target dir
|
||||
$target_dir = dirname(__FILE__,2).'/settings/translations/';
|
||||
//Filename
|
||||
$input_file = $target_dir.'translations_'.strtoupper($language_key).'.php';
|
||||
//store translation to the file
|
||||
file_put_contents($input_file, $translation);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user