Skip to content

Commit

Permalink
feat(Locale): add vi and it (alibaba-fusion#2051)
Browse files Browse the repository at this point in the history
* feat(Locale): add vi and it

Co-authored-by: shanruo.wj <[email protected]>
  • Loading branch information
youluna and shanruo.wj authored Jul 30, 2020
1 parent 4c166bf commit efd5da9
Show file tree
Hide file tree
Showing 9 changed files with 308 additions and 39 deletions.
2 changes: 2 additions & 0 deletions index-with-locales.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ next.locales['ja-ja'] = require('./lib/locale/ja-jp.js');
next.locales['zh-cn'] = require('./lib/locale/zh-cn.js');
next.locales['zh-hk'] = require('./lib/locale/zh-hk.js');
next.locales['zh-tw'] = require('./lib/locale/zh-tw.js');
next.locales['vi-vn'] = require('./lib/locale/vi-vn.js');
next.locales['it-it'] = require('./lib/locale/it-it.js');

module.exports = next;
5 changes: 5 additions & 0 deletions scripts/build/export-api-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export default ${exportName};
const file = path.basename(localePath).replace('.js', '');
const tsLibPath = path.join(cwd, 'lib', 'locale', `${file}.d.ts`);
const tsEsPath = path.join(cwd, 'es', 'locale', `${file}.d.ts`);
const tsPath = path.join(cwd, 'types', 'locale', `${file}.d.ts`);

if (!fs.existsSync(tsPath)) {
fs.writeFileSync(tsPath, `export * from './default';`);
}

fs.writeFileSync(tsLibPath, `export * from '../../types/locale/${file}';`);
fs.writeFileSync(tsEsPath, `export * from '../../types/locale/${file}';`);
Expand Down
47 changes: 10 additions & 37 deletions scripts/init-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,13 @@ const options = {
'lib/popup.scss',
],
theme: {
main: [
'theme/form-element.jsx',
'theme/mask.jsx',
'theme/popup.jsx',
],
main: ['theme/form-element.jsx', 'theme/mask.jsx', 'theme/popup.jsx'],
entryName: pathname => {
const themeName = path.basename(pathname, '.jsx');
return `demos/${themeName}`;
},
deps: (pathname, entry) => {
const stylePath = path.join(
cwd,
'src',
entry.name,
'style.js'
);
const stylePath = path.join(cwd, 'src', entry.name, 'style.js');

let styleConetent = '';
if (fs.existsSync(stylePath)) {
Expand All @@ -59,17 +50,12 @@ const options = {
const match2 = line.match(PATTERN_IMPORT2);

// eslint-disable-next-line
match1
? arr.push(match1[1])
: match2
? arr.push(match2[1])
: '';
match1 ? arr.push(match1[1]) : match2 ? arr.push(match2[1]) : '';
});

return arr.filter(
(current, index, arr) =>
['config-provider', entry.name].indexOf(current) ===
-1 && index === arr.indexOf(current)
['config-provider', entry.name].indexOf(current) === -1 && index === arr.indexOf(current)
);
},
},
Expand All @@ -82,28 +68,20 @@ const options = {
'lib/zh-cn.js',
'lib/zh-hk.js',
'lib/zh-tw.js',
'lib/vi-vn.js',
'lib/it-it.js',
],
},
{
match: PATTERN_NEXT,
main: [
'lib/index.js',
'lib/index.jsx',
'lib/index.scss',
'lib/api-schema.json',
],
main: ['lib/index.js', 'lib/index.jsx', 'lib/index.scss', 'lib/api-schema.json'],
theme: {
main: 'theme/index.jsx',
entryName: (pathname, entry) => {
return `demos/${entry.name.replace(PATTERN_NEXT, '$1')}`;
},
deps: (pathname, entry) => {
const stylePath = path.join(
cwd,
'src',
entry.name,
'style.js'
);
const stylePath = path.join(cwd, 'src', entry.name, 'style.js');
const styleConetent = fs.readFileSync(stylePath, 'utf8');
const themeConetent = fs.readFileSync(pathname, 'utf8');
const importContent = themeConetent.match(/^import.*;$/gm);
Expand All @@ -118,17 +96,12 @@ const options = {
const match2 = line.match(PATTERN_IMPORT2);

// eslint-disable-next-line
match1
? arr.push(match1[1])
: match2
? arr.push(match2[1])
: '';
match1 ? arr.push(match1[1]) : match2 ? arr.push(match2[1]) : '';
});

return arr.filter(
(current, index, arr) =>
['config-provider', entry.name].indexOf(current) ===
-1 && index === arr.indexOf(current)
['config-provider', entry.name].indexOf(current) === -1 && index === arr.indexOf(current)
);
},
},
Expand Down
4 changes: 3 additions & 1 deletion site/zh-cn/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
| 繁体中文 | zh-tw |
| 美式英语 | en-us |
| 日文 | ja-jp |
| 越南语 | vi-vn |
| 意大利语 | it-it |

### 指定多语言文案

目前 Fusion 内置的 locale 库支持中英繁日四种语言,覆盖各组件的简单词汇,例如:确定、取消、展开、收起、下一页等, 简单词汇映射表可参考 https://unpkg.com/@alifd/next/lib/locale/
目前 Fusion 内置的 locale 库支持上述几种语言,覆盖各组件的简单词汇,例如:确定、取消、展开、收起、下一页等, 简单词汇映射表可参考 https://unpkg.com/@alifd/next/lib/locale/

可通过两种方式设置多语言文案,两种方式接收的对象格式略有不同:
1. 设置组件自身 locale 属性
Expand Down
141 changes: 141 additions & 0 deletions src/locale/it-it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/* italian */
export default {
momentLocale: 'it',
Timeline: {
expand: 'Espandi',
fold: 'Riduci',
},
Balloon: {
close: 'Chiudi',
},
Card: {
expand: 'Espandi',
fold: 'Riduci',
},
Calendar: {
today: 'Oggi',
now: 'Ora',
ok: 'OK',
clear: 'Cancella',
month: 'Mese',
year: 'Anno',
prevYear: 'Anno precedente',
nextYear: 'Prossimo anno',
prevMonth: 'Mese precedente',
nextMonth: 'Prossimo mese',
prevDecade: 'Decennio precedente',
nextDecade: 'Prossimo decennio',
yearSelectAriaLabel: 'Seleziona anno',
monthSelectAriaLabel: 'Seleziona mese',
},
DatePicker: {
placeholder: 'Seleziona data',
datetimePlaceholder: 'Seleziona data e orario',
monthPlaceholder: 'Seleziona mese',
yearPlaceholder: 'Seleziona anno',
weekPlaceholder: 'Selezionare settimana',
now: 'Ora',
selectTime: 'Seleziona orario',
selectDate: 'Seleziona data',
ok: 'OK',
clear: 'Cancella',
startPlaceholder: 'Data di inizio',
endPlaceholder: 'Data di fine',
hour: 'H',
minute: 'M',
second: 'S',
},
Dialog: {
close: 'Chiudi',
ok: 'OK',
cancel: 'Annulla',
},
Drawer: {
close: 'Chiudi',
},
Message: {
closeAriaLabel: 'Chiudi',
},
Pagination: {
prev: 'Precedente',
next: 'Successivo',
goTo: 'Vai a',
page: 'Pagina',
go: 'Visualizza',
total: 'Pagina {current}, {total} pagine',
labelPrev: 'Pagina precedente, pagina corrente {current}',
labelNext: 'Pagina successiva, pagina corrente {current}',
inputAriaLabel: 'Inserisci a quale pagina saltare',
selectAriaLabel:
'Seleziona il numero di elementi visualizzati in ogni pagina',
pageSize: 'Articoli per pagina:',
},
Input: {
clear: 'Cancella',
},
Select: {
selectPlaceholder: 'Seleziona',
autoCompletePlaceholder: 'Inserisci',
notFoundContent: 'Nessuna opzione',
maxTagPlaceholder: '{selected} selezionati/{total} totali',
selectAll: 'Seleziona tutto',
},
Table: {
empty: 'Nessun dato',
ok: 'OK',
reset: 'Ripristina',
asc: 'Ordine ascendente',
desc: 'Ordine decrescente',
expanded: 'Espanso',
folded: 'Ridotto',
filter: 'Filtro',
selectAll: 'Seleziona tutto',
},
TimePicker: {
placeholder: 'Seleziona orario',
clear: 'Cancella',
hour: 'H',
minute: 'M',
second: 'S',
},
Transfer: {
items: 'articoli',
item: 'articolo',
moveAll: 'Sposta tutto',
searchPlaceholder: 'Inserisci',
moveToLeft: 'Deseleziona elementi selezionati',
moveToRight: 'Inviare elementi selezionati',
},
Upload: {
card: {
cancel: 'Annulla',
addPhoto: 'Aggiungi immagine',
download: 'Scarica',
delete: 'Elimina',
},
drag: {
text: "Seleziona o trascina il file in quest'area per caricarlo'",
hint:
'Supporta il caricamento di docx, xls, PDF, rar, zip, PNG, JPG e altri file',
},
upload: {
delete: 'Elimina',
},
},
Search: {
buttonText: 'Cerca',
},
Tag: {
delete: 'Elimina',
},
Rating: {
description: 'Opzioni di valutazione',
},
Switch: {
on: 'on',
off: 'off',
},
Tab: {
closeAriaLabel: 'Chiudi',
},
};
Loading

0 comments on commit efd5da9

Please sign in to comment.