Browse Source

add content language selection #14

main
ghost 1 year ago
parent
commit
0d840a5ab5
  1. 23
      src/app/controller/page.php
  2. 24
      src/app/view/theme/default/page/form/description.phtml
  3. 104
      src/config/locales.json
  4. 1
      src/public/assets/theme/default/css/common.css

23
src/app/controller/page.php

@ -46,9 +46,32 @@ class AppControllerPage
public function renderFormDescription() public function renderFormDescription()
{ {
// Prepare locales
$locales = [];
foreach (Environment::config('locales') as $key => $value)
{
$locales[$key] = (object)
[
'key' => $key,
'value' => $value[0],
'active' => false !== stripos($_SERVER['HTTP_ACCEPT_LANGUAGE'], $key) ? true : false,
];
}
// Init form // Init form
$form = (object) $form = (object)
[ [
'locale' => (object)
[
'error' => [],
'values' => $locales,
'attribute' => (object)
[
'value' => null,
'placeholder' => _('Page content language'),
]
],
'title' => (object) 'title' => (object)
[ [
'error' => [], 'error' => [],

24
src/app/view/theme/default/page/form/description.phtml

@ -13,6 +13,30 @@
<h1><?php echo _('Submit') ?></h1> <h1><?php echo _('Submit') ?></h1>
</div> </div>
<form class="margin-t-8" name="submit" method="post" enctype="multipart/form-data" action="page/form"> <form class="margin-t-8" name="submit" method="post" enctype="multipart/form-data" action="page/form">
<div class="margin-b-16">
<label for="locale">
<?php echo _('Content language') ?>
</label>
<sub class="opacity-0 parent-hover-opacity-09"
title="<?php echo $form->locale->attribute->placeholder ?>">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" class="bi bi-info-circle-fill" viewBox="0 0 16 16">
<path d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm.93-9.412-1 4.705c-.07.34.029.533.304.533.194 0 .487-.07.686-.246l-.088.416c-.287.346-.92.598-1.465.598-.703 0-1.002-.422-.808-1.319l.738-3.468c.064-.293.006-.399-.287-.47l-.451-.081.082-.381 2.29-.287zM8 5.5a1 1 0 1 1 0-2 1 1 0 0 1 0 2z"/>
</svg>
</sub>
<select class="width-100 margin-t-8" type="text" name="locale" id="locale">
<?php foreach ($form->locale->values as $locale) { ?>
<?php if ($locale->active) { ?>
<option value="<?php echo $locale->key ?>" selected="selected">
<?php echo $locale->value ?>
</option>
<?php } else { ?>
<option value="<?php echo $locale->key ?>">
<?php echo $locale->value ?>
</option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="margin-b-16"> <div class="margin-b-16">
<label for="title"> <label for="title">
<?php echo _('Title') ?> <?php echo _('Title') ?>

104
src/config/locales.json

@ -1,5 +1,5 @@
{ {
"af_ZA": "af-ZA":
[ [
"Afrikaans", "Afrikaans",
"Afrikaans" "Afrikaans"
@ -9,77 +9,77 @@
"العربية", "العربية",
"Arabic" "Arabic"
], ],
"bg_BG": "bg-BG":
[ [
"Български", "Български",
"Bulgarian" "Bulgarian"
], ],
"ca_AD": "ca-AD":
[ [
"Català", "Català",
"Catalan" "Catalan"
], ],
"cs_CZ": "cs-CZ":
[ [
"Čeština", "Čeština",
"Czech" "Czech"
], ],
"cy_GB": "cy-GB":
[ [
"Cymraeg", "Cymraeg",
"Welsh" "Welsh"
], ],
"da_DK": "da-DK":
[ [
"Dansk", "Dansk",
"Danish" "Danish"
], ],
"de_AT": "de-AT":
[ [
"Deutsch (Österreich)", "Deutsch (Österreich)",
"German (Austria)" "German (Austria)"
], ],
"de_CH": "de-CH":
[ [
"Deutsch (Schweiz)", "Deutsch (Schweiz)",
"German (Switzerland)" "German (Switzerland)"
], ],
"de_DE": "de-DE":
[ [
"Deutsch (Deutschland)", "Deutsch (Deutschland)",
"German (Germany)" "German (Germany)"
], ],
"el_GR": "el-GR":
[ [
"Ελληνικά", "Ελληνικά",
"Greek" "Greek"
], ],
"en_GB": "en-GB":
[ [
"English (UK)", "English (UK)",
"English (UK)" "English (UK)"
], ],
"en_US": "en-US":
[ [
"English (US)", "English (US)",
"English (US)" "English (US)"
], ],
"es_CL": "es-CL":
[ [
"Español (Chile)", "Español (Chile)",
"Spanish (Chile)" "Spanish (Chile)"
], ],
"es_ES": "es-ES":
[ [
"Español (España)", "Español (España)",
"Spanish (Spain)" "Spanish (Spain)"
], ],
"es_MX": "es-MX":
[ [
"Español (México)", "Español (México)",
"Spanish (Mexico)" "Spanish (Mexico)"
], ],
"et_EE": "et-EE":
[ [
"Eesti keel", "Eesti keel",
"Estonian" "Estonian"
@ -89,77 +89,77 @@
"Euskara", "Euskara",
"Basque" "Basque"
], ],
"fa_IR": "fa-IR":
[ [
"فارسی", "فارسی",
"Persian" "Persian"
], ],
"fi_FI": "fi-FI":
[ [
"Suomi", "Suomi",
"Finnish" "Finnish"
], ],
"fr_CA": "fr-CA":
[ [
"Français (Canada)", "Français (Canada)",
"French (Canada)" "French (Canada)"
], ],
"fr_FR": "fr-FR":
[ [
"Français (France)", "Français (France)",
"French (France)" "French (France)"
], ],
"gl_ES": "gl-ES":
[ [
"Galego (Spain)", "Galego (Spain)",
"Galician (Spain)" "Galician (Spain)"
], ],
"he_IL": "he-IL":
[ [
"עברית", "עברית",
"Hebrew" "Hebrew"
], ],
"hi_IN": "hi-IN":
[ [
"हि", "हि",
"Hindi" "Hindi"
], ],
"hr_HR": "hr-HR":
[ [
"Hrvatski", "Hrvatski",
"Croatian" "Croatian"
], ],
"hu_HU": "hu-HU":
[ [
"Magyar", "Magyar",
"Hungarian" "Hungarian"
], ],
"id_ID": "id-ID":
[ [
"Bahasa Indonesia", "Bahasa Indonesia",
"Indonesian" "Indonesian"
], ],
"is_IS": "is-IS":
[ [
"Íslenska", "Íslenska",
"Icelandic" "Icelandic"
], ],
"it_IT": "it-IT":
[ [
"Italiano", "Italiano",
"Italian" "Italian"
], ],
"ja_JP": "ja-JP":
[ [
"日本語", "日本語",
"Japanese" "Japanese"
], ],
"km_KH": "km-KH":
[ [
"ភរ", "ភរ",
"Khmer" "Khmer"
], ],
"ko_KR": "ko-KR":
[ [
"한국어", "한국어",
"Korean" "Korean"
@ -169,107 +169,107 @@
"Latina", "Latina",
"Latin" "Latin"
], ],
"lt_LT": "lt-LT":
[ [
"Lietuvių kalba", "Lietuvių kalba",
"Lithuanian" "Lithuanian"
], ],
"lv_LV": "lv-LV":
[ [
"Latviešu", "Latviešu",
"Latvian" "Latvian"
], ],
"mn_MN": "mn-MN":
[ [
"Монгол", "Монгол",
"Mongolian" "Mongolian"
], ],
"nb_NO": "nb-NO":
[ [
"Norsk bokmål", "Norsk bokmål",
"Norwegian (Bokmål)" "Norwegian (Bokmål)"
], ],
"nl_NL": "nl-NL":
[ [
"Nederlands", "Nederlands",
"Dutch" "Dutch"
], ],
"nn_NO": "nn-NO":
[ [
"Norsk nynorsk", "Norsk nynorsk",
"Norwegian (Nynorsk)" "Norwegian (Nynorsk)"
], ],
"pl_PL": "pl-PL":
[ [
"Polski", "Polski",
"Polish" "Polish"
], ],
"pt_BR": "pt-BR":
[ [
"Português (Brasil)", "Português (Brasil)",
"Portuguese (Brazil)" "Portuguese (Brazil)"
], ],
"pt_PT": "pt-PT":
[ [
"Português (Portugal)", "Português (Portugal)",
"Portuguese (Portugal)" "Portuguese (Portugal)"
], ],
"ro_RO": "ro-RO":
[ [
"Română", "Română",
"Romanian" "Romanian"
], ],
"ru_RU": "ru-RU":
[ [
"Русский", "Русский",
"Russian" "Russian"
], ],
"sk_SK": "sk-SK":
[ [
"Slovenčina", "Slovenčina",
"Slovak" "Slovak"
], ],
"sl_SI": "sl-SI":
[ [
"Slovenščina", "Slovenščina",
"Slovenian" "Slovenian"
], ],
"sr_RS": "sr-RS":
[ [
"Српски / Srpski", "Српски / Srpski",
"Serbian" "Serbian"
], ],
"sv_SE": "sv-SE":
[ [
"Svenska", "Svenska",
"Swedish" "Swedish"
], ],
"th_TH": "th-TH":
[ [
"ไทย", "ไทย",
"Thai" "Thai"
], ],
"tr_TR": "tr-TR":
[ [
"Türkçe", "Türkçe",
"Turkish" "Turkish"
], ],
"uk_UA": "uk-UA":
[ [
"Українська", "Українська",
"Ukrainian" "Ukrainian"
], ],
"vi_VN": "vi-VN":
[ [
"Tiếng Việt", "Tiếng Việt",
"Vietnamese" "Vietnamese"
], ],
"zh_CN": "zh-CN":
[ [
"中文 (中国大陆)", "中文 (中国大陆)",
"Chinese (PRC)" "Chinese (PRC)"
], ],
"zh_TW": "zh-TW":
[ [
"中文 (台灣)", "中文 (台灣)",
"Chinese (Taiwan)" "Chinese (Taiwan)"

1
src/public/assets/theme/default/css/common.css

@ -48,6 +48,7 @@ a:active h2 {
} }
input, input,
select,
textarea { textarea {
background: #5d627d; background: #5d627d;
color: #ccc; color: #ccc;

Loading…
Cancel
Save