CMXX - Product attributes and initial multi languagal product support

This commit is contained in:
“VeLiTi”
2025-01-14 14:40:01 +01:00
parent 906ce7b843
commit 05b0c2bdb1
18 changed files with 234 additions and 202 deletions

View File

@@ -2921,29 +2921,42 @@ function getRelativeTime($timestamp) {
function generateLanguageFile($language_key,$token){
function generateFile($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;
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);
}
}
if ($language_key != ''){
generateFile($language_key,$token);
} else {
include_once dirname(__FILE__,2).'/settings/settingsmenu.php';
foreach ($supportedLanguages as $language){
generateFile($language,$token);
}
//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);
}
}
}