From ad00a5b2aa0cff5e35cde09610811e4fa76f957d Mon Sep 17 00:00:00 2001 From: Nico Hoffmann Date: Sat, 18 May 2024 17:35:11 +0200 Subject: [PATCH] i18n --- i18n/de.json | 4 ++++ i18n/en.json | 4 ++++ i18n/index.php | 15 +++++++++++++++ index.js | 2 +- index.php | 3 ++- src/CsvField.vue | 4 ++-- 6 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 i18n/de.json create mode 100644 i18n/en.json create mode 100644 i18n/index.php diff --git a/i18n/de.json b/i18n/de.json new file mode 100644 index 0000000..28a670e --- /dev/null +++ b/i18n/de.json @@ -0,0 +1,4 @@ +{ + "field.csv.empty": "Wähle die CSV-Datei aus oder lade sie hoch", + "field.csv.loading": "Lade Tabelle…" +} diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..d61cfe8 --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,4 @@ +{ + "field.csv.empty": "Select or upload CSV file", + "field.csv.loading": "Loading table…" +} diff --git a/i18n/index.php b/i18n/index.php new file mode 100644 index 0000000..047ff42 --- /dev/null +++ b/i18n/index.php @@ -0,0 +1,15 @@ +[this.columns[e].key??e,this.columns[e]])):this.rows?Object.fromEntries(Object.keys(this.rows[0]).map(e=>[e,{label:e}])):[]},file(){return this.value[0]},pagination(){return{details:!0,limit:this.limit,page:this.page,total:this.rows.length}},rowsPaginated(){return this.limit?this.rows.slice((this.page-1)*this.limit,this.page*this.limit):this.rows}},watch:{file:{async handler(e){this.rows=null,e&&(this.rows=await this.$api.get(this.endpoints.field+"/preview",{file:e.id}))},immediate:!0}}};var h=function(){var t=this,n=t._self._c;return n("k-field",t._b({staticClass:"k-models-field k-csv-field",scopedSlots:t._u([t.disabled?null:{key:"options",fn:function(){return[t.file?n("k-button",{attrs:{responsive:!0,text:t.$t("remove"),icon:"remove",size:"xs",variant:"filled"},on:{click:function(a){return t.remove(0)}}}):n("k-button-group",{ref:"buttons",staticClass:"k-field-options",attrs:{buttons:t.buttons,layout:"collapsed",size:"xs",variant:"filled"}})]},proxy:!0}],null,!0)},"k-field",t.$props,!1),[n("k-dropzone",{attrs:{disabled:!t.hasDropzone},on:{drop:t.drop}},[t.rows?n("k-table",{attrs:{columns:t.cols,rows:t.rowsPaginated,pagination:t.pagination},on:{paginate:function(a){t.page=a.page}}}):t.file?n("k-empty",{attrs:{text:"Loading table…",icon:"loader",layout:"table"}}):n("k-empty",{attrs:{icon:"table",layout:"table",text:"Select or upload CSV file"},on:{click:t.open}})],1)],1)},_=[],m=c(p,h,_,!1,null,null,null,null);const v=m.exports;panel.plugin("distantnative/kirby-csv-field",{fields:{csv:v}})})(); +(function(){"use strict";function c(e,t,s,a,r,l,u,b){var i=typeof e=="function"?e.options:e;t&&(i.render=t,i.staticRenderFns=s,i._compiled=!0),a&&(i.functional=!0),l&&(i._scopeId="data-v-"+l);var o;if(u?(o=function(n){n=n||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!n&&typeof __VUE_SSR_CONTEXT__<"u"&&(n=__VUE_SSR_CONTEXT__),r&&r.call(this,n),n&&n._registeredComponents&&n._registeredComponents.add(u)},i._ssrRegister=o):r&&(o=b?function(){r.call(this,(i.functional?this.parent:this).$root.$options.shadowRoot)}:r),o)if(i.functional){i._injectStyles=o;var g=i.render;i.render=function(k,d){return o.call(d),g(k,d)}}else{var f=i.beforeCreate;i.beforeCreate=f?[].concat(f,o):[o]}return{exports:e,options:i}}const p={extends:"k-files-field",props:{columns:Object,limit:Number},data(){return{rows:null,page:1}},computed:{cols(){return this.columns?Object.fromEntries(Object.keys(this.columns).map(e=>[this.columns[e].key??e,this.columns[e]])):this.rows?Object.fromEntries(Object.keys(this.rows[0]).map(e=>[e,{label:e}])):[]},file(){return this.value[0]},pagination(){return{details:!0,limit:this.limit,page:this.page,total:this.rows.length}},rowsPaginated(){return this.limit?this.rows.slice((this.page-1)*this.limit,this.page*this.limit):this.rows}},watch:{file:{async handler(e){this.rows=null,e&&(this.rows=await this.$api.get(this.endpoints.field+"/preview",{file:e.id}))},immediate:!0}}};var h=function(){var t=this,s=t._self._c;return s("k-field",t._b({staticClass:"k-models-field k-csv-field",scopedSlots:t._u([t.disabled?null:{key:"options",fn:function(){return[t.file?s("k-button",{attrs:{responsive:!0,text:t.$t("remove"),icon:"remove",size:"xs",variant:"filled"},on:{click:function(a){return t.remove(0)}}}):s("k-button-group",{ref:"buttons",staticClass:"k-field-options",attrs:{buttons:t.buttons,layout:"collapsed",size:"xs",variant:"filled"}})]},proxy:!0}],null,!0)},"k-field",t.$props,!1),[s("k-dropzone",{attrs:{disabled:!t.hasDropzone},on:{drop:t.drop}},[t.rows?s("k-table",{attrs:{columns:t.cols,rows:t.rowsPaginated,pagination:t.pagination},on:{paginate:function(a){t.page=a.page}}}):t.file?s("k-empty",{attrs:{text:t.$t("field.csv.loading"),icon:"loader",layout:"table"}}):s("k-empty",{attrs:{text:t.$t("field.csv.empty"),icon:"table",layout:"table"},on:{click:t.open}})],1)],1)},m=[],_=c(p,h,m,!1,null,null,null,null);const v=_.exports;panel.plugin("distantnative/kirby-csv-field",{fields:{csv:v}})})(); diff --git a/index.php b/index.php index 0984dd0..bb46bec 100644 --- a/index.php +++ b/index.php @@ -95,5 +95,6 @@ function csv(string $file, string $delimiter = ','): array return []; } - ] + ], + 'translations' => require_once __DIR__ . '/i18n/index.php' ]); diff --git a/src/CsvField.vue b/src/CsvField.vue index 7dd012a..0df6b9d 100644 --- a/src/CsvField.vue +++ b/src/CsvField.vue @@ -31,15 +31,15 @@ />