1.1.0 • Published 8 months ago

vue-automated-i18n v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

vue-automated-i18n

📚 Introduction

This repository automates Vue SFC locales in the i18n custom block, which processes importing locales from JSON, exporting locales to JSON, adding new fields, or adding new locale options.

⚒️ Used Technologies

  • @vue/compiler-sfc
  • Yargs
  • Prettier

Getting Started

For using the project follow the steps below

Installation

You can clone the project with the following URL.

git clone https://github.com/trombonist76/vue-automated-i18n.git
yarn

Script Usages

A. Adding New Locale

Script: yarn add-locale

Example: yarn add-locale --localeKey az --extendKey tr

Shorthand yarn add-locale -l az -e tr

npx npx -p vue-automated-i18n add-locale add-locale -l az -e tr -d src/components

Builder Opts.AliasDefaultRequiredExampleDescription
localeKey-lnonetruetrNew locale option to be added to the component.
extendKey-enonefalseenThe locale whose translations will be transferred to new locale.
dir-dsrc/componentsfalse-The components directory or path that will be added to new locale.

Add Locale

B. Adding New Field to Component

NOTE: You can add nested fields with using (.) dot. Ex: this.is.nested { this: { is: { nested: givenValue }}}

Script: yarn add-field

Example: `yarn add-field --component Button --fieldName submit --fieldValue OK -d src/components

Nested - Example: yarn add-field --component Header --fieldName title.header --fieldValue "Header Title"

Shorthand yarn add-field -c Button -f submit -v OK

npx npx -p vue-automated-i18n add-field add-field -f submit -v OK -d src/components

Builder Opts.AliasDefaultRequiredExampleDescription
component-cnonetrueButtonThe component name, without the '.vue', to which a new field will be added.
fieldName-fnonetruenewFieldThe field name to be added to component as a object key.
fieldValue-vnonetruehi, im valueThe field value of the new field to be added to component as a object value.
dir-dsrc/componentsfalsesrc/components/ModalThe component directory that will be added to new field.

Add Field

C. Adding New Field to All Components

NOTE: You can add nested fields with using (.) dot. Ex: this.is.nested { this: { is: { nested: givenValue }}}

Script: yarn add-field-all

Example: yarn add-field-all --fieldName submit --fieldValue OK --dir src/components

Nested - Example: yarn add-field-all --fieldName title.header --fieldValue "Header Title" --dir src/components

Shorthand yarn add-field-all -f submit -v OK -d src/components

npx npx -p vue-automated-i18n add-field-all add-field-all -f submit -v OK -d src/components

Builder Opts.AliasDefaultRequiredExampleDescription
fieldName-fnonetruenewFieldThe field name to be added to component as a object key.
fieldValue-vnonetruehi, im valueThe field value of the new field to be added to component as a object value.
dir-dsrc/componentsfalsesrc/viewsThe components directory or path that will be added to new field.

Add Field All

D. Importing locales from JSON

NOTE: The JSON file must be like this:

{
	"src/components/Button": {
		"en": {
			"submit": "OK"
		},
		"tr": {
			"submit": "tamam"
		},
	},
	"src/components/Header": {
		"en": {
			"title": "Header Title"
		},
		"tr": {
			"title": "Header Başlığı"
		},
	}
	// and other files
}

Script: yarn import-locales

Example: yarn import-locales --importFilePath src/imports/locales.json --dir src/components

Shorthand yarn import-locales -p src/imports/locales.json -d src/components

npx npx -p vue-automated-i18n import-locales import-locales -p src/imports/locales.json -d src/components

Builder Opts.AliasDefaultRequiredExampleDescription
importFilePath-pnonetrueimport/locales.jsonThe path of JSON file to be imported its translations to components.
dir-dsrc/componentsfalsesrc/viewsThe components directory or path that will be added to locales from JSON.

Import Locales

E. Exporting locales from JSON

Script: yarn export-locales

Example: yarn export-locales --exportFilePath src/exports/locales.json --dir src/components

Shorthand yarn export-locales -p src/exports/locales.json -d src/components

npx npx -p vue-automated-i18n export-locales export-locales -p src/exports/locales.json -d src/components

Builder Opts.AliasDefaultRequiredExampleDescription
exportFilePath-ptranslations.jsonfalseexport/locales.jsonThe path of JSON file to be exported components translations.
dir-dsrc/componentsfalsesrc/viewsThe components directory or path that will be added to locales from JSON.
component-cnonefalseHeaderThe specific component name, without the '.vue', to which its translations will be exported.
nested-ntruefalseboolean ex: falseSearch components in nested folder structure.

Export Locales

1.1.0

8 months ago

1.0.26

8 months ago

1.0.25

8 months ago

1.0.24

8 months ago

1.0.23

8 months ago

1.0.22

8 months ago

1.0.21

8 months ago

1.0.20

8 months ago

1.0.19

8 months ago

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago