Skip to content

Commit

Permalink
fix: translate subfields label
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jan 23, 2024
1 parent 85a55a1 commit 4f2bbad
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
12 changes: 12 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ other = "Body"
[cms_field_label_categories]
other = "Categories"

[cms_field_label_category]
other = "Category"

[cms_field_label_date]
other = "Date"

Expand All @@ -22,9 +25,15 @@ other = "Draft"
[cms_field_label_expiry_date]
other = "Expiry Date"

[cms_field_label_image]
other = "Image"

[cms_field_label_images]
other = "Images"

[cms_field_label_keyword]
other = "Keyword"

[cms_field_label_keywords]
other = "Keywords"

Expand All @@ -49,6 +58,9 @@ other = "Slug"
[cms_field_label_summary]
other = "Summary"

[cms_field_label_tag]
other = "Tag"

[cms_field_label_tags]
other = "Tags"

Expand Down
12 changes: 12 additions & 0 deletions i18n/zh-hans.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ other = "正文"
[cms_field_label_categories]
other = "分类"

[cms_field_label_category]
other = "分类"

[cms_field_label_date]
other = "日期"

Expand All @@ -22,9 +25,15 @@ other = "草稿"
[cms_field_label_expiry_date]
other = "有效期"

[cms_field_label_image]
other = "图片"

[cms_field_label_images]
other = "图片"

[cms_field_label_keyword]
other = "关键词"

[cms_field_label_keywords]
other = "关键词"

Expand All @@ -49,6 +58,9 @@ other = "Slug"
[cms_field_label_summary]
other = "摘要"

[cms_field_label_tag]
other = "标签"

[cms_field_label_tags]
other = "标签"

Expand Down
12 changes: 12 additions & 0 deletions i18n/zh-hant.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ other = "正文"
[cms_field_label_categories]
other = "分類"

[cms_field_label_category]
other = "分類"

[cms_field_label_date]
other = "日期"

Expand All @@ -22,9 +25,15 @@ other = "草稿"
[cms_field_label_expiry_date]
other = "有效期"

[cms_field_label_image]
other = "圖片"

[cms_field_label_images]
other = "圖片"

[cms_field_label_keyword]
other = "關鍵詞"

[cms_field_label_keywords]
other = "關鍵詞"

Expand All @@ -49,6 +58,9 @@ other = "Slug"
[cms_field_label_summary]
other = "摘要"

[cms_field_label_tag]
other = "標籤"

[cms_field_label_tags]
other = "標籤"

Expand Down
15 changes: 14 additions & 1 deletion layouts/partials/decap-cms/functions/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,21 @@
{{- $tmp := newScratch }}
{{- $tmp.Set "field" . }}
{{- $tmp.DeleteInMap "field" "_weight" }}
{{- $label := default .label (printf "cms_field_label_%s" (replace (lower .label) " " "_") | i18n) }}
{{- $label := partial "decap-cms/functions/translate-label" .label }}
{{- $tmp.SetInMap "field" "label" $label }}
{{- with index . "field" }}
{{- $childLabel := partial "decap-cms/functions/translate-label" .label }}
{{- $tmp.SetInMap "field" "field" (merge . (dict "label" $childLabel)) }}
{{- end }}
{{- with index . "fields" }}
{{- $children := slice }}
{{- range . }}
{{- $childLabel := partial "decap-cms/functions/translate-label" .label }}
{{- $child := . }}
{{- $children = $children | append (merge . (dict "label" $childLabel)) }}
{{- end }}
{{- $tmp.SetInMap "field" "fields" $children }}
{{- end }}
{{- $collection.Add "fields" (slice ($tmp.Get "field")) }}
{{- end }}
{{- end -}}
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/decap-cms/functions/translate-label.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ return default . (printf "cms_field_label_%s" (replace (lower .) " " "_") | i18n) }}

0 comments on commit 4f2bbad

Please sign in to comment.