Skip to content

Commit

Permalink
refactor(i18n): move type outside
Browse files Browse the repository at this point in the history
  • Loading branch information
zyf722 committed Jun 27, 2024
1 parent 4f42bd6 commit e66fd1d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions scripts/i18n-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ const sortedJSONify = (obj, space = 2) =>

/**
* Write translation to .ts and .lokalise.json files.
* @param {'translation' | 'languageInfo'} namespace
* @param {boolean} overwriteMode
* @param {'translation' | 'languageInfo'} namespace
* @param {boolean} overwriteMode
*/
const writeTranslation = async (namespace, overwriteMode) => {
const name = namespace === 'translation' ? 'translation' : 'languageInfo';
const type = namespace === 'translation' ? 'I18nTranslation' : 'I18nLangInfoTranslation';
const code = `import { type I18nTranslationTemplate } from '../models';
const code = `import type { I18nTranslationTemplate } from '../models';
// This is used as a template for other translations.
// Other translations should be typed like this:
Expand Down Expand Up @@ -103,7 +103,7 @@ const writeTranslation = async (namespace, overwriteMode) => {
/**
* Add a translation entry to `trans` and `structuredJSON`.
* @param {string} nsKey Key with namespace.
* @param {string} value
* @param {string} value
* @param {string} desc Description for Lokalise.
* @param {string[]} props Props that needs to be translated.
*/
Expand Down Expand Up @@ -142,9 +142,9 @@ const addTranslation = (nsKey, value, desc, props) => {

/**
* Abstractify HTML string. Convert all tags to a format like `<0>`, `<1>`, etc.
*
*
* Should be kept same as the one in `src/livecodes/i18n/utils.ts`.
*
*
* @param {string} html The HTML string to abstractify.
* @returns The abstractified HTML string, with a list of objects of their tag names and attributes.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/i18n/locales/en/language-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type I18nTranslationTemplate } from '../models';
import type { I18nTranslationTemplate } from '../models';

// This is used as a template for other translations.
// Other translations should be typed like this:
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/i18n/locales/en/translation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type I18nTranslationTemplate } from '../models';
import type { I18nTranslationTemplate } from '../models';

// This is used as a template for other translations.
// Other translations should be typed like this:
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/i18n/locales/tmp/language-info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type I18nTranslationTemplate } from '../models';
import type { I18nTranslationTemplate } from '../models';

// This is used as a template for other translations.
// Other translations should be typed like this:
Expand Down
2 changes: 1 addition & 1 deletion src/livecodes/i18n/locales/tmp/translation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type I18nTranslationTemplate } from '../models';
import type { I18nTranslationTemplate } from '../models';

// This is used as a template for other translations.
// Other translations should be typed like this:
Expand Down

0 comments on commit e66fd1d

Please sign in to comment.