diff --git a/Admin/Install/db.json b/Admin/Install/db.json index ea3c2de..33a3b76 100644 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -201,6 +201,11 @@ "foreignTable": "currency", "foreignKey": "currency_code" }, + "l11n_currency_format": { + "name": "l11n_currency_format", + "type": "VARCHAR(20)", + "null": false + }, "l11n_number_thousand": { "name": "l11n_number_thousand", "type": "VARCHAR(20)", @@ -404,6 +409,48 @@ "type": "VARCHAR(20)", "default": null, "null": true + }, + "l11n_datetime_delim_date": { + "name": "l11n_datetime_delim_date", + "type": "VARCHAR(1)", + "default": null, + "null": true + }, + "l11n_datetime_delim_time": { + "name": "l11n_datetime_delim_time", + "type": "VARCHAR(1)", + "default": null, + "null": true + }, + "l11n_datetime_very_short": { + "name": "l11n_datetime_very_short", + "type": "VARCHAR(20)", + "default": null, + "null": true + }, + "l11n_datetime_short": { + "name": "l11n_datetime_short", + "type": "VARCHAR(20)", + "default": null, + "null": true + }, + "l11n_datetime_medium": { + "name": "l11n_datetime_medium", + "type": "VARCHAR(20)", + "default": null, + "null": true + }, + "l11n_datetime_long": { + "name": "l11n_datetime_long", + "type": "VARCHAR(20)", + "default": null, + "null": true + }, + "l11n_datetime_very_long": { + "name": "l11n_datetime_very_long", + "type": "VARCHAR(20)", + "default": null, + "null": true } } }, diff --git a/Controller/ApiController.php b/Controller/ApiController.php index e485be2..ca98beb 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -46,6 +46,7 @@ use phpOMS\Uri\Http; use phpOMS\Utils\Parser\Markdown\Markdown; use phpOMS\Validation\Network\Email; use phpOMS\Version\Version; +use phpOMS\Localization\Localization; /** * Admin controller class. @@ -519,6 +520,20 @@ final class ApiController extends Controller $account->setEmail((string) ($request->getData('email') ?? '')); $account->generatePassword((string) ($request->getData('password') ?? '')); + if ($request->getData('lang') === null) { + $account->setL11n( + Localization::fromJson( + $this->app->l11nServer === null ? $request->getHeader()->getL11n()->jsonSerialize() : $this->app->l11nServer->jsonSerialize() + ) + ); + } else { + $l11n = $account->getL11n(); + $l11n->loadFromLanguage( + (string) ($request->getData('lang')), + (string) ($request->getData('country') ?? $this->app->l11nServer->getCountry()) + ); + } + return $account; } diff --git a/Models/AccountMapper.php b/Models/AccountMapper.php index 25bdd58..13cb263 100644 --- a/Models/AccountMapper.php +++ b/Models/AccountMapper.php @@ -36,18 +36,19 @@ final class AccountMapper extends DataMapperAbstract * @since 1.0.0 */ protected static array $columns = [ - 'account_id' => ['name' => 'account_id', 'type' => 'int', 'internal' => 'id', 'autocomplete' => true], - 'account_status' => ['name' => 'account_status', 'type' => 'int', 'internal' => 'status'], - 'account_type' => ['name' => 'account_type', 'type' => 'int', 'internal' => 'type'], - 'account_login' => ['name' => 'account_login', 'type' => 'string', 'internal' => 'login', 'autocomplete' => true], - 'account_name1' => ['name' => 'account_name1', 'type' => 'string', 'internal' => 'name1', 'autocomplete' => true, 'annotations' => ['gdpr' => true]], - 'account_name2' => ['name' => 'account_name2', 'type' => 'string', 'internal' => 'name2', 'autocomplete' => true, 'annotations' => ['gdpr' => true]], - 'account_name3' => ['name' => 'account_name3', 'type' => 'string', 'internal' => 'name3', 'autocomplete' => true, 'annotations' => ['gdpr' => true]], - 'account_password' => ['name' => 'account_password', 'type' => 'string', 'internal' => 'password'], - 'account_email' => ['name' => 'account_email', 'type' => 'string', 'internal' => 'email', 'autocomplete' => true, 'annotations' => ['gdpr' => true]], - 'account_tries' => ['name' => 'account_tries', 'type' => 'int', 'internal' => 'tries'], - 'account_lactive' => ['name' => 'account_lactive', 'type' => 'DateTime', 'internal' => 'lastActive'], - 'account_created_at' => ['name' => 'account_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], + 'account_id' => ['name' => 'account_id', 'type' => 'int', 'internal' => 'id', 'autocomplete' => true], + 'account_status' => ['name' => 'account_status', 'type' => 'int', 'internal' => 'status'], + 'account_type' => ['name' => 'account_type', 'type' => 'int', 'internal' => 'type'], + 'account_login' => ['name' => 'account_login', 'type' => 'string', 'internal' => 'login', 'autocomplete' => true], + 'account_name1' => ['name' => 'account_name1', 'type' => 'string', 'internal' => 'name1', 'autocomplete' => true, 'annotations' => ['gdpr' => true]], + 'account_name2' => ['name' => 'account_name2', 'type' => 'string', 'internal' => 'name2', 'autocomplete' => true, 'annotations' => ['gdpr' => true]], + 'account_name3' => ['name' => 'account_name3', 'type' => 'string', 'internal' => 'name3', 'autocomplete' => true, 'annotations' => ['gdpr' => true]], + 'account_password' => ['name' => 'account_password', 'type' => 'string', 'internal' => 'password'], + 'account_email' => ['name' => 'account_email', 'type' => 'string', 'internal' => 'email', 'autocomplete' => true, 'annotations' => ['gdpr' => true]], + 'account_tries' => ['name' => 'account_tries', 'type' => 'int', 'internal' => 'tries'], + 'account_lactive' => ['name' => 'account_lactive', 'type' => 'DateTime', 'internal' => 'lastActive'], + 'account_localization' => ['name' => 'account_localization', 'type' => 'int', 'internal' => 'localization'], + 'account_created_at' => ['name' => 'account_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'], ]; /** diff --git a/Models/LocalizationMapper.php b/Models/LocalizationMapper.php index 3c1ae17..8941f24 100644 --- a/Models/LocalizationMapper.php +++ b/Models/LocalizationMapper.php @@ -38,14 +38,52 @@ final class LocalizationMapper extends DataMapperAbstract * @since 1.0.0 */ protected static array $columns = [ - 'l11n_id' => ['name' => 'l11n_id', 'type' => 'int', 'internal' => 'id'], - 'l11n_country' => ['name' => 'l11n_country', 'type' => 'string', 'internal' => 'country'], - 'l11n_language' => ['name' => 'l11n_language', 'type' => 'string', 'internal' => 'language'], - 'l11n_currency' => ['name' => 'l11n_currency', 'type' => 'string', 'internal' => 'currency'], - 'l11n_number_thousand' => ['name' => 'l11n_number_thousand', 'type' => 'string', 'internal' => 'thousands'], - 'l11n_number_decimal' => ['name' => 'l11n_number_decimal', 'type' => 'string', 'internal' => 'decimal'], - 'l11n_angle' => ['name' => 'l11n_angle', 'type' => 'string', 'internal' => 'angle'], - 'l11n_temperature' => ['name' => 'l11n_temperature', 'type' => 'string', 'internal' => 'temperature'], + 'l11n_id' => ['name' => 'l11n_id', 'type' => 'int', 'internal' => 'id'], + 'l11n_country' => ['name' => 'l11n_country', 'type' => 'string', 'internal' => 'country'], + 'l11n_language' => ['name' => 'l11n_language', 'type' => 'string', 'internal' => 'language'], + 'l11n_currency' => ['name' => 'l11n_currency', 'type' => 'string', 'internal' => 'currency'], + 'l11n_currency_format' => ['name' => 'l11n_currency_format', 'type' => 'string', 'internal' => 'currencyFormat'], + 'l11n_number_thousand' => ['name' => 'l11n_number_thousand', 'type' => 'string', 'internal' => 'thousands'], + 'l11n_number_decimal' => ['name' => 'l11n_number_decimal', 'type' => 'string', 'internal' => 'decimal'], + 'l11n_angle' => ['name' => 'l11n_angle', 'type' => 'string', 'internal' => 'angle'], + 'l11n_temperature' => ['name' => 'l11n_temperature', 'type' => 'string', 'internal' => 'temperature'], + 'l11n_weight_very_light' => ['name' => 'l11n_weight_very_light', 'type' => 'string', 'internal' => 'weight/very_light'], + 'l11n_weight_light' => ['name' => 'l11n_weight_light', 'type' => 'string', 'internal' => 'weight/light'], + 'l11n_weight_medium' => ['name' => 'l11n_weight_medium', 'type' => 'string', 'internal' => 'weight/medium'], + 'l11n_weight_heavy' => ['name' => 'l11n_weight_heavy', 'type' => 'string', 'internal' => 'weight/heavy'], + 'l11n_weight_very_heavy' => ['name' => 'l11n_weight_very_heavy', 'type' => 'string', 'internal' => 'weight/very_heavy'], + 'l11n_speed_very_slow' => ['name' => 'l11n_speed_very_slow', 'type' => 'string', 'internal' => 'speed/very_slow'], + 'l11n_speed_slow' => ['name' => 'l11n_speed_slow', 'type' => 'string', 'internal' => 'speed/slow'], + 'l11n_speed_medium' => ['name' => 'l11n_speed_medium', 'type' => 'string', 'internal' => 'speed/medium'], + 'l11n_speed_fast' => ['name' => 'l11n_speed_fast', 'type' => 'string', 'internal' => 'speed/fast'], + 'l11n_speed_very_fast' => ['name' => 'l11n_speed_very_fast', 'type' => 'string', 'internal' => 'speed/very_fast'], + 'l11n_speed_sea' => ['name' => 'l11n_speed_sea', 'type' => 'string', 'internal' => 'speed/sea'], + 'l11n_length_very_short' => ['name' => 'l11n_length_very_short', 'type' => 'string', 'internal' => 'length/very_short'], + 'l11n_length_short' => ['name' => 'l11n_length_short', 'type' => 'string', 'internal' => 'length/short'], + 'l11n_length_medium' => ['name' => 'l11n_length_medium', 'type' => 'string', 'internal' => 'length/medium'], + 'l11n_length_long' => ['name' => 'l11n_length_long', 'type' => 'string', 'internal' => 'length/long'], + 'l11n_length_very_long' => ['name' => 'l11n_length_very_long', 'type' => 'string', 'internal' => 'length/very_long'], + 'l11n_length_sea' => ['name' => 'l11n_length_sea', 'type' => 'string', 'internal' => 'length/sea'], + 'l11n_area_very_small' => ['name' => 'l11n_area_very_small', 'type' => 'string', 'internal' => 'area/very_small'], + 'l11n_area_small' => ['name' => 'l11n_area_small', 'type' => 'string', 'internal' => 'area/small'], + 'l11n_area_medium' => ['name' => 'l11n_area_medium', 'type' => 'string', 'internal' => 'area/medium'], + 'l11n_area_large' => ['name' => 'l11n_area_large', 'type' => 'string', 'internal' => 'area/large'], + 'l11n_area_very_large' => ['name' => 'l11n_area_very_large', 'type' => 'string', 'internal' => 'area/very_large'], + 'l11n_volume_very_small' => ['name' => 'l11n_volume_very_small', 'type' => 'string', 'internal' => 'volume/very_small'], + 'l11n_volume_small' => ['name' => 'l11n_volume_small', 'type' => 'string', 'internal' => 'volume/small'], + 'l11n_volume_medium' => ['name' => 'l11n_volume_medium', 'type' => 'string', 'internal' => 'volume/medium'], + 'l11n_volume_large' => ['name' => 'l11n_volume_large', 'type' => 'string', 'internal' => 'volume/large'], + 'l11n_volume_very_large' => ['name' => 'l11n_volume_very_large', 'type' => 'string', 'internal' => 'volume/very_large'], + 'l11n_volume_teaspoon' => ['name' => 'l11n_volume_teaspoon', 'type' => 'string', 'internal' => 'volume/teaspoon'], + 'l11n_volume_tablespoon' => ['name' => 'l11n_volume_tablespoon', 'type' => 'string', 'internal' => 'volume/tablespoon'], + 'l11n_volume_glass' => ['name' => 'l11n_volume_glass', 'type' => 'string', 'internal' => 'volume/glass'], + 'l11n_datetime_delim_date' => ['name' => 'l11n_datetime_delim_date', 'type' => 'string', 'internal' => 'dateDelim'], + 'l11n_datetime_delim_time' => ['name' => 'l11n_datetime_delim_time', 'type' => 'string', 'internal' => 'timeDelim'], + 'l11n_datetime_very_short' => ['name' => 'l11n_datetime_very_short', 'type' => 'string', 'internal' => 'datetime/very_short'], + 'l11n_datetime_short' => ['name' => 'l11n_datetime_short', 'type' => 'string', 'internal' => 'datetime/short'], + 'l11n_datetime_medium' => ['name' => 'l11n_datetime_medium', 'type' => 'string', 'internal' => 'datetime/medium'], + 'l11n_datetime_long' => ['name' => 'l11n_datetime_long', 'type' => 'string', 'internal' => 'datetime/long'], + 'l11n_datetime_very_long' => ['name' => 'l11n_datetime_very_long', 'type' => 'string', 'internal' => 'datetime/very_long'], ]; /**