Make units for lengths and weights translatable
This commit is contained in:
parent
64bb16616c
commit
4d6e0f03fd
2
l18n
2
l18n
|
@ -1 +1 @@
|
|||
Subproject commit 38c989b971471a0b69fe486cedf1d35587640ce8
|
||||
Subproject commit 11c3524f1f3a2df9878878df362e2ce8fcfe3f63
|
|
@ -9,9 +9,33 @@ declare(strict_types = 1);
|
|||
/**
|
||||
* Class containing available units for weights, lengths etc.
|
||||
*/
|
||||
class MDUnitsSet {
|
||||
class MDUnitsSet extends MDValueSet {
|
||||
|
||||
const UNITS_LENGTH = ['', 'm', 'dm', 'cm', 'mm'];
|
||||
const UNITS_WEIGHT = ['', 't', 'kg', 'g'];
|
||||
|
||||
/**
|
||||
* Returns a translated list of length units.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
function getLengthUnitsTLed(MDTlLoader $tlLoader):array {
|
||||
return parent::getTlUnsortedList($tlLoader, self::UNITS_LENGTH, "units_length_set", "units_length_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a translated list of weight units.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
function getWeightUnitsTLed(MDTlLoader $tlLoader):array {
|
||||
return parent::getTlUnsortedList($tlLoader, self::UNITS_WEIGHT, "units_weight_set", "units_weight_set");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,28 @@ declare(strict_types = 1);
|
|||
*/
|
||||
class MDValueSet {
|
||||
|
||||
/**
|
||||
* Gets an unsorted array based on provided keys and their translations.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
* @param array<string> $keyList List of keys to get translations for.
|
||||
* @param string $tlFileName Name of the translation file.
|
||||
* @param string $tlVarName Variable of the translation.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getTlUnsortedList(MDTlLoader $tlLoader, array $keyList, string $tlFileName, string $tlVarName):array {
|
||||
|
||||
$output = [];
|
||||
foreach ($keyList as $tID) {
|
||||
if ($tID === "") $output[$tID] = "";
|
||||
else $output[$tID] = $tlLoader->tl($tlFileName, $tlVarName, $tID);
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of entries in a translated version.
|
||||
*
|
||||
|
@ -23,12 +45,7 @@ class MDValueSet {
|
|||
*/
|
||||
public static function getTlSortedList(MDTlLoader $tlLoader, array $keyList, string $tlFileName, string $tlVarName):array {
|
||||
|
||||
$output = [];
|
||||
foreach ($keyList as $tID) {
|
||||
if ($tID === "") $output[$tID] = "";
|
||||
else $output[$tID] = $tlLoader->tl($tlFileName, $tlVarName, $tID);
|
||||
}
|
||||
|
||||
$output = self::getTlUnsortedList($tlLoader, $keyList, $tlFileName, $tlVarName);
|
||||
asort($output);
|
||||
return $output;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user