Skip to content

Commit

Permalink
feat: extract i18n keys (#291)
Browse files Browse the repository at this point in the history
Signed-off-by: David Dal Busco <[email protected]>
  • Loading branch information
peterpeterparker authored Nov 6, 2023
1 parent 249ab2f commit 4e754ce
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/frontend/src/lib/components/docs/DocForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

<p class="title doc-form">
{#if isActive}
{$i18n.document.title_add_new_document}
{$i18n.document_form.title_add_new_document}
{:else}
&ZeroWidthSpace;
{/if}
Expand All @@ -103,20 +103,20 @@
<article class="doc-form" in:fade>
<form on:submit|preventDefault={onSubmit}>
<Value ref="doc-id">
<svelte:fragment slot="label">{$i18n.document.field_doc_id_label}</svelte:fragment>
<svelte:fragment slot="label">{$i18n.document_form.field_doc_id_label}</svelte:fragment>
<div class="form-doc-id">
<input
id="doc-id"
type="text"
placeholder={$i18n.document.field_doc_id_placeholder}
placeholder={$i18n.document_form.field_doc_id_placeholder}
name="doc_id"
bind:value={key}
/>
<button
class="text action start"
type="button"
on:click={() => (key = nanoid())}
aria-label={$i18n.document.field_doc_id_btn_auto_id}
aria-label={$i18n.document_form.field_doc_id_btn_auto_id}
>
<IconAutoRenew />
</button>
Expand All @@ -135,7 +135,7 @@

<button class="text action start" type="button" on:click={onAddFieldButtonPressed}>
<IconNew size="16px" />
<span>{$i18n.document.btn_add_field}</span>
<span>{$i18n.document_form.btn_add_field}</span>
</button>

<div class="button-wrapper">
Expand Down
20 changes: 10 additions & 10 deletions src/frontend/src/lib/components/docs/DocFormField.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,44 @@
<div class="form-field">
<div class="form-field-item">
<Value ref="field-name">
<svelte:fragment slot="label">{$i18n.document.field_name_label}</svelte:fragment>
<svelte:fragment slot="label">{$i18n.document_form.field_name_label}</svelte:fragment>
<input
id="field-name"
name="field-name"
type="text"
placeholder={$i18n.document.field_name_placeholder}
placeholder={$i18n.document_form.field_name_placeholder}
bind:value={name}
/>
</Value>
</div>

<div class="form-field-item">
<Value ref="field-type">
<svelte:fragment slot="label">{$i18n.document.field_type_label}</svelte:fragment>
<svelte:fragment slot="label">{$i18n.document_form.field_type_label}</svelte:fragment>
<select id="field-type" name="field-type" bind:value={fieldType}>
<option value={DocFieldTypeEnum.BOOLEAN}>{$i18n.document.field_type_boolean}</option>
<option value={DocFieldTypeEnum.STRING}>{$i18n.document.field_type_string}</option>
<option value={DocFieldTypeEnum.NUMBER}>{$i18n.document.field_type_number}</option>
<option value={DocFieldTypeEnum.BOOLEAN}>{$i18n.document_form.field_type_boolean}</option>
<option value={DocFieldTypeEnum.STRING}>{$i18n.document_form.field_type_string}</option>
<option value={DocFieldTypeEnum.NUMBER}>{$i18n.document_form.field_type_number}</option>
</select>
</Value>
</div>

<div class="form-field-item">
<Value>
<svelte:fragment slot="label">{$i18n.document.field_value_label}</svelte:fragment>
<svelte:fragment slot="label">{$i18n.document_form.field_value_label}</svelte:fragment>

<div class="value-input-wrapper">
{#if fieldType === DocFieldTypeEnum.NUMBER || fieldType === DocFieldTypeEnum.STRING}
<input
type={fieldType === DocFieldTypeEnum.STRING ? 'text' : 'number'}
placeholder={$i18n.document.field_value_label}
placeholder={$i18n.document_form.field_value_label}
/>
{/if}

{#if fieldType === DocFieldTypeEnum.BOOLEAN}
<select bind:value>
<option value={true}>{$i18n.document.field_value_true}</option>
<option value={false}>{$i18n.document.field_value_false}</option>
<option value={true}>{$i18n.document_form.field_value_true}</option>
<option value={false}>{$i18n.document_form.field_value_false}</option>
</select>
{/if}

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/lib/components/docs/Docs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<button
class="text action start"
on:click={() => docsStore.set({ key: undefined, data: undefined, action: 'create' })}
><IconNew size="16px" /> <span>{$i18n.document.btn_add_document}</span></button
><IconNew size="16px" /> <span>{$i18n.document_form.btn_add_document}</span></button
>
{/if}

Expand Down
4 changes: 3 additions & 1 deletion src/frontend/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@
"delete": "Delete document?",
"description": "Description",
"document_submission_success": "Document has been successfully submitted!",
"document_submission_failed": "Document submission failed!",
"document_submission_failed": "Document submission failed!"
},
"document_form": {
"field_doc_id_label": "Doc ID",
"field_doc_id_btn_auto_id": "Auto ID",
"field_doc_id_placeholder": "Document ID",
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/src/lib/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@
"delete": "Vuoi eliminare il documento?",
"description": "Descrizione",
"document_submission_success": "Il documento è stato inviato con successo!",
"document_submission_failed": "Invio del documento non riuscito!",
"document_submission_failed": "Invio del documento non riuscito!"
},
"document_form": {
"field_doc_id_label": "Doc ID",
"field_doc_id_btn_auto_id": "Auto ID",
"field_doc_id_placeholder": "ID documento",
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/src/lib/i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@
"delete": "删除文档?",
"description": "描述",
"document_submission_success": "文件已成功提交!",
"document_submission_failed": "文件提交失败!",
"document_submission_failed": "文件提交失败!"
},
"document_form": {
"field_doc_id_label": "Doc ID",
"field_doc_id_btn_auto_id": "Auto ID",
"field_doc_id_placeholder": "文件编号",
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/src/lib/types/i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ interface I18nDocument {
description: string;
document_submission_success: string;
document_submission_failed: string;
}

interface I18nDocument_form {
field_doc_id_label: string;
field_doc_id_btn_auto_id: string;
field_doc_id_placeholder: string;
Expand Down Expand Up @@ -483,6 +486,7 @@ interface I18n {
cli: I18nCli;
errors: I18nErrors;
document: I18nDocument;
document_form: I18nDocument_form;
asset: I18nAsset;
admin: I18nAdmin;
controllers: I18nControllers;
Expand Down

0 comments on commit 4e754ce

Please sign in to comment.