Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add json indent config #222

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
- [`exclude`](#exclude)
- [`noEmptyTranslation`](#noemptytranslation)
- [`missingtranslationstring`](#missingtranslationstring)
- [`jsonIndentation`](#jsonIndentation)
- [Supported `vue-i18n` Formats](#supported-vue-i18n-formats)
- [Why?](#why)
- [Contribution](#contribution)
Expand Down Expand Up @@ -221,6 +222,17 @@ You can generate a default configuration file using `npx vue-i18n-extract init`
* `'Translation missing'`: Use "Translation missing" as default key.
* `null`: Add the translation key to the file, but don't add a default translation. This will trigger `vue-i18n`'s the missingHandler.

### `jsonIndentation`

* Name: `jsonIndentation`
* CLI argument: `--json-indentation`, `--jsonIndentation`
* Required: No
* Default: `2`
* Type: `number` or `null`
* Description: Number of spaces to use when writing JSON files.
* Examples:
* `4`

## Supported `vue-i18n` Formats

- Static in template or script:
Expand Down
4 changes: 4 additions & 0 deletions bin/vue-i18n-extract.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ cli
'--missingTranslationString',
'Default string for missing translations.'
)
.option(
'--jsonIndentation',
'Indentation to be used when writing JSON files.'
)
.option(
'--detect <detectionType>',
'[string] The type of issues you want to detect (ex. --detect missing) ',
Expand Down
4 changes: 2 additions & 2 deletions dist/create-report/language-files.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
import { SimpleFile, I18NLanguage, I18NItem } from '../types';
export declare function readLanguageFiles(src: string): SimpleFile[];
export declare function extractI18NLanguageFromLanguageFiles(languageFiles: SimpleFile[], dot?: DotObject.Dot): I18NLanguage;
export declare function writeMissingToLanguageFiles(parsedLanguageFiles: SimpleFile[], missingKeys: I18NItem[], dot?: DotObject.Dot, noEmptyTranslation?: string, missingTranslationString?: string): void;
export declare function removeUnusedFromLanguageFiles(parsedLanguageFiles: SimpleFile[], unusedKeys: I18NItem[], dot?: DotObject.Dot): void;
export declare function writeMissingToLanguageFiles(parsedLanguageFiles: SimpleFile[], missingKeys: I18NItem[], dot?: DotObject.Dot, noEmptyTranslation?: string, missingTranslationString?: string, jsonIndentation?: number): void;
export declare function removeUnusedFromLanguageFiles(parsedLanguageFiles: SimpleFile[], unusedKeys: I18NItem[], dot?: DotObject.Dot, jsonIndentation?: number): void;
export declare function parselanguageFiles(languageFiles: string, dot?: DotObject.Dot): I18NLanguage;
13 changes: 7 additions & 6 deletions dist/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export declare type ReportOptions = {
export type ReportOptions = {
vueFiles: string;
languageFiles: string;
output?: string;
Expand All @@ -9,32 +9,33 @@ export declare type ReportOptions = {
separator?: string;
noEmptyTranslation?: string;
missingTranslationString?: string;
jsonIndentation?: number;
detect?: DetectionType[];
};
export declare enum DetectionType {
Missing = "missing",
Unused = "unused",
Dynamic = "dynamic"
}
export declare type SimpleFile = {
export type SimpleFile = {
fileName: string;
path: string;
content: string;
};
export declare type I18NItem = {
export type I18NItem = {
line?: number;
path: string;
file?: string;
language?: string;
};
export declare type I18NItemWithBounding = I18NItem & {
export type I18NItemWithBounding = I18NItem & {
previousCharacter: string;
nextCharacter: string;
};
export declare type I18NLanguage = {
export type I18NLanguage = {
[language: string]: I18NItem[];
};
export declare type I18NReport = {
export type I18NReport = {
missingKeys: I18NItem[];
unusedKeys: I18NItem[];
maybeDynamicKeys: I18NItem[];
Expand Down
Loading