Skip to content

Commit

Permalink
feat: umi-plugin-sula 简化多语言配置
Browse files Browse the repository at this point in the history
  • Loading branch information
xz8la8 committed Apr 26, 2021
1 parent d01b9e6 commit 856e024
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/sula/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sula",
"version": "1.2.0-beta.55",
"version": "1.2.0-beta.56",
"module": "./es/index.js",
"main": "./es/index.js",
"types": "./es/index.d.ts",
Expand Down
6 changes: 1 addition & 5 deletions packages/sula/src/template-create-form/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
import { default as _CreateForm, CreateFormProps as _CreateFormProps } from './CreateForm';

export interface CreateFormProps extends _CreateFormProps {}

export const CreateForm = _CreateForm;
export { default as CreateForm } from './CreateForm';
6 changes: 2 additions & 4 deletions packages/sula/src/template-query-table/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
import { default as QueryTable, QueryTableProps } from './QueryTable';
import { default as QueryForm, QueryFormProps } from './QueryForm';

export { QueryTable, QueryForm, QueryTableProps, QueryFormProps };
export { default as QueryTable } from './QueryTable';
export { default as QueryForm } from './QueryForm';
6 changes: 1 addition & 5 deletions packages/sula/src/template-step-form/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
import { default as _StepForm, StepFormProps as _StepFormProps } from './StepForm';

export interface StepFormProps extends _StepFormProps {}

export const StepForm = _StepForm;
export { default as StepForm } from './StepForm';
6 changes: 1 addition & 5 deletions packages/sula/src/template-step-query-table/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
import { default as _StepQueryTable ,StepQueryTableProps as _StepQueryTableProps } from './StepQueryTable';

export interface StepQueryTableProps extends _StepQueryTableProps {}

export const StepQueryTable = _StepQueryTable;
export { default as StepQueryTable } from './StepQueryTable';
2 changes: 1 addition & 1 deletion packages/umi-plugin-sula/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "umi-plugin-sula",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"main": "lib/index.js",
"peerDependencies": {
"sula": "^1.0.0-beta.1",
Expand Down
13 changes: 9 additions & 4 deletions packages/umi-plugin-sula/template/configProvider.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import React from 'react';
import { ConfigProvider } from 'sula';
import { history } from 'umi';
import { history, getLocale } from 'umi';

const baseSeparator = '{{{baseSeparator}}}' || '-';
const formatLangFile = (lang) => lang && lang.replace(baseSeparator, '_');

function getLocale() {
const lang = '{{{default}}}' || `en${baseSeparator}US`;
function getLocaleData() {
let lang;
try {
lang = getLocale();
} catch (error) {
lang = '{{{default}}}' || `en${baseSeparator}US`;
}
const langFile = formatLangFile(lang);

let locale;
Expand All @@ -19,7 +24,7 @@ function getLocale() {

export const rootContainer = (container) => {
return (
<ConfigProvider locale={getLocale()} history={history}>
<ConfigProvider locale={getLocaleData()} history={history}>
{container}
</ConfigProvider>
);
Expand Down

0 comments on commit 856e024

Please sign in to comment.