<xf:if is="$language.isInsert()">
	<xf:title>{{ phrase('add_language') }}</xf:title>
<xf:else />
	<xf:title>{{ phrase('edit_language:') }} {$language.title}</xf:title>
</xf:if>

<xf:pageaction if="$language.isUpdate()">
	<xf:button href="{{ link('languages/delete', $language) }}" icon="delete" overlay="true" />
</xf:pageaction>

<xf:form action="{{ link('languages/save', $language) }}" ajax="true" class="block">
	<div class="block-container">
		<div class="block-body">
			<xf:textboxrow name="title" value="{$language.title}" maxlength="{{ max_length($language, 'title') }}"
				label="{{ phrase('title') }}" />

			<xf:selectrow name="parent_id" value="{$language.parent_id}"
				label="{{ phrase('parent_language') }}">
				<xf:option value="0">{{ phrase('(no_parent)') }}</xf:option>
				<xf:foreach loop="$languageTree.getFlattened(1)" value="$treeEntry">
					<xf:option value="{$treeEntry.record.language_id}"
						label="{{ repeat('--', $treeEntry.depth) }} {$treeEntry.record.title}" />
				</xf:foreach>
			</xf:selectrow>

			<xf:selectrow name="language_code" value="{$language.language_code}"
				label="{{ phrase('locale') }}">

				<xf:option value="">&nbsp;</xf:option>
				<xf:options source="$locales" />
			</xf:selectrow>

			<xf:radiorow name="text_direction" value="{$language.text_direction}"
				label="{{ phrase('text_direction') }}">

				<xf:option value="LTR">{{ phrase('left_to_right') }}</xf:option>
				<xf:option value="RTL">{{ phrase('right_to_left') }}</xf:option>
			</xf:radiorow>

			<xf:checkboxrow>
				<xf:option name="user_selectable" selected="{$language.user_selectable}">
					{{ phrase('allow_user_selection') }}
				</xf:option>
			</xf:checkboxrow>

			<hr class="formRowSep" />

			<xf:textboxrow name="decimal_point" value="{$language.decimal_point}" size="5" class="input--autoSize"
				maxlength="{{ max_length($language, 'decimal_point') }}"
				label="{{ phrase('decimal_point_character') }}" />

			<xf:textboxrow name="thousands_separator" value="{$language.thousands_separator}" size="5" class="input--autoSize"
				maxlength="{{ max_length($language, 'thousands_separator') }}"
				label="{{ phrase('thousands_separator') }}" />

			<xf:textboxrow name="label_separator" value="{$language.label_separator}" size="5" class="input--autoSize"
				maxlength="{{ max_length($language, 'label_separator') }}"
				label="{{ phrase('label_separator') }}"
				explain="{{ phrase('this_is_used_to_separate_labels_from_their_associated_values') }}" />

			<xf:textboxrow name="comma_separator" value="{$language.comma_separator}" size="5" class="input--autoSize"
				maxlength="{{ max_length($language, 'comma_separator') }}"
				label="{{ phrase('comma_separator') }}"
				explain="{{ phrase('this_is_used_as_separator_in_lists_of_values') }}" />

			<xf:textboxrow name="ellipsis" value="{$language.ellipsis}" size="5" class="input--autoSize"
				maxlength="{{ max_length($language, 'ellipsis') }}"
				label="{{ phrase('ellipsis_character') }}" />

			<xf:formrow label="{{ phrase('parentheses_characters') }}">

				<div class="inputGroup">
					<xf:textbox name="parenthesis_open" value="{$language.parenthesis_open}" size="5" class="input--autoSize"
						maxlength="{{ max_length($language, 'parenthesis_open') }}" />
					<span class="inputGroup-splitter"></span>
					<xf:textbox name="parenthesis_close" value="{$language.parenthesis_close}" size="5" class="input--autoSize"
						maxlength="{{ max_length($language, 'parenthesis_close') }}" />
				</div>
			</xf:formrow>

			<hr class="formRowSep" />

			<xf:selectrow name="week_start" value="{$language.week_start}"
				label="{{ phrase('week_start_day') }}">

				<xf:option value="0">{{ phrase('day_sunday') }}</xf:option>
				<xf:option value="1">{{ phrase('day_monday') }}</xf:option>
				<xf:option value="2">{{ phrase('day_tuesday') }}</xf:option>
				<xf:option value="3">{{ phrase('day_wednesday') }}</xf:option>
				<xf:option value="4">{{ phrase('day_thursday') }}</xf:option>
				<xf:option value="5">{{ phrase('day_friday') }}</xf:option>
				<xf:option value="6">{{ phrase('day_saturday') }}</xf:option>
			</xf:selectrow>

			<xf:radiorow name="date_format" value="{$language.date_format}"
				label="{{ phrase('date_format') }}">

				<xf:options source="$dateFormats" />
				<xf:option value="" selected="!{$dateFormats.{$language.date_format}}"
					label="{{ phrase('other') }}">
					<xf:dependent>
						<xf:textbox name="date_format_other" value="{{ {$dateFormats.{$language.date_format}} ? '' : $language.date_format }}"
							size="15" maxlength="{{ max_length($language, 'date_format') }}"
							dir="ltr" />
						<p class="formRow-explain">{{ phrase('use_php_date_format') }}</p>
					</xf:dependent>
				</xf:option>
			</xf:radiorow>

			<hr class="formRowSep" />

			<xf:radiorow name="time_format" value="{$language.time_format}"
				label="{{ phrase('time_format') }}">

				<xf:options source="$timeFormats" />
				<xf:option value="" selected="!{$timeFormats.{$language.time_format}}" label="{{ phrase('other') }}">
					<xf:dependent>
						<xf:textbox name="time_format_other" value="{{ {$timeFormats.{$language.time_format}} ? '' : $language.time_format }}"
							size="15" maxlength="{{ max_length($language, 'time_format') }}"
							dir="ltr" />
						<p class="formRow-explain">{{ phrase('use_php_time_format') }}</p>
					</xf:dependent>
				</xf:option>
			</xf:radiorow>

			<hr class="formRowSep" />

			<xf:radiorow name="currency_format" value="{$language.currency_format}"
				label="{{ phrase('currency_format') }}">

				<xf:options source="$currencyFormats" />
				<xf:option value="" selected="!{$currencyFormats.{$language.currency_format}}" label="{{ phrase('other') }}">
					<xf:dependent>
						<xf:textbox name="currency_format_other" value="{{ {$currencyFormats.{$language.currency_format}} ? '' : $language.currency_format }}"
							size="15" maxlength="{{ max_length($language, 'currency_format') }}" />
						<p class="formRow-explain">{{ phrase('currency_format_explain') }}</p>
					</xf:dependent>
				</xf:option>
			</xf:radiorow>

		</div>

		<xf:if is="$quickPhrases is not empty">
			<h3 class="block-formSectionHeader">
				<span class="collapseTrigger collapseTrigger--block" data-xf-click="toggle" data-target="< :up:next">
					<span class="block-formSectionHeader-aligner">{{ phrase('commonly_edited_phrases') }}</span>
				</span>
			</h3>
			<div class="block-body block-body--collapsible">
				<xf:textarearow name="quick_phrases[privacy_policy_text]"
					value="{$quickPhrases.privacy_policy_text.phrase_text}"
					label="{{ phrase('privacy_policy') }}"
					hint="{{ phrase('you_may_use_html') }}"
					autosize="true"
					class="input--fitHeight--short" />

				<xf:textarearow name="quick_phrases[terms_rules_text]"
					value="{$quickPhrases.terms_rules_text.phrase_text}"
					label="{{ phrase('terms_and_rules') }}"
					hint="{{ phrase('you_may_use_html') }}"
					autosize="true"
					class="input--fitHeight--short" />

				<xf:textarearow name="quick_phrases[extra_copyright]"
					value="{$quickPhrases.extra_copyright.phrase_text}"
					label="{{ phrase('extra_footer_copyright') }}"
					hint="{{ phrase('you_may_use_html') }}"
					autosize="true"
					class="input--fitHeight--short"/>

				<xf:textarearow name="quick_phrases[email_footer_html]"
					value="{$quickPhrases.email_footer_html.phrase_text}"
					label="{{ phrase('extra_email_footer_html') }}"
					hint="{{ phrase('you_may_use_html') }}"
					autosize="true"
					class="input--fitHeight--short"/>

				<xf:textarearow name="quick_phrases[email_footer_text]"
					value="{$quickPhrases.email_footer_text.phrase_text}"
					label="{{ phrase('extra_email_footer_plain_text') }}"
					autosize="true"
					class="input--fitHeight--short"/>
			</div>
		</xf:if>

		<xf:submitrow sticky="true" icon="save" />
	</div>
</xf:form>