-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from Ten-Do/localization
Add the ruRU locale and refactoring a localization logic
- Loading branch information
Showing
62 changed files
with
338 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.logout_button { | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react' | ||
import { useNav } from '../../navigation/NavContext' | ||
import { useLocaleProvider } from '../../locale' | ||
import { useSafeSetState } from '../../utils/hooks' | ||
import { Button } from '../../ui/Button' | ||
import useLogout from '../useLogout' | ||
import styles from './Logout.module.scss' | ||
|
||
export function Logout() { | ||
const { toggle } = useNav() | ||
const logout = useLogout() | ||
const [loading, setLoading] = useSafeSetState(false) | ||
const { auth: locale } = useLocaleProvider() | ||
|
||
const onClick = () => { | ||
setLoading(true) | ||
return logout().finally(() => { | ||
setLoading(false) | ||
toggle() | ||
}) | ||
} | ||
|
||
return ( | ||
<Button | ||
className={styles.logout_button} | ||
type="button" | ||
view="ghost" | ||
loading={loading} | ||
onClick={onClick} | ||
> | ||
{locale.logout} | ||
</Button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { AuthLocale } from '../interfaces' | ||
|
||
export const enUS: AuthLocale = { | ||
login: 'Login', | ||
logout: 'Exit', | ||
oauth: 'Or continue with', | ||
password: 'Password', | ||
email: 'Email', | ||
notification: { | ||
success: 'You are successfully logged in', | ||
error: 'Login failed', | ||
}, | ||
} |
1 change: 1 addition & 0 deletions
1
admiral/crud/locale/actions/index.ts → admiral/auth/locale/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './enUS' | ||
export * from './ruRU' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { AuthLocale } from '../interfaces' | ||
|
||
export const ruRU: AuthLocale = { | ||
login: 'Войти', | ||
logout: 'Выйти', | ||
oauth: 'Или войти с помощью', | ||
password: 'Пароль', | ||
email: 'Электронная почта', | ||
notification: { | ||
success: 'Вы успешно вошли в систему', | ||
error: 'Не удалось войти в систему', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
admiral/crud/locale/actions/enUS.ts → admiral/crud/locales/enUS.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './enUS' | ||
export * from './ruRU' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { CRUDActionsLocale } from '../interfaces' | ||
|
||
export const ruRU: CRUDActionsLocale = { | ||
submit: 'Подтвердить', | ||
back: 'Назад', | ||
tableColumn: 'Действия', | ||
paginationTotal: (total) => `Всего ${total}`, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { PopconfirmLocaleType } from '../ui/Popconfirm/interfaces' | ||
|
||
export type DataTableType = { | ||
title: string | ||
} & PopconfirmLocaleType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { enUs as enUsPopconfirmLocale } from '../../ui/Popconfirm/locale/enUS' | ||
import { PopconfirmLocaleType } from '../../ui/Popconfirm/interfaces' | ||
import { enUS as enUsPopconfirmLocale } from '../../ui/Popconfirm/locale/enUS' | ||
import { DataTableType } from '../interfaces' | ||
|
||
export type DataTableType = { | ||
title: string | ||
} & PopconfirmLocaleType | ||
|
||
export const enUs: DataTableType = { | ||
export const enUS: DataTableType = { | ||
title: 'Are you sure you want to delete?', | ||
...enUsPopconfirmLocale, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './enUS' | ||
export * from './ruRU' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { DataTableType } from '../interfaces' | ||
import { ruRU as ruRuPopconfirmLocale } from '../../ui/Popconfirm/locale' | ||
|
||
export const ruRU: DataTableType = { | ||
title: 'Вы уверены, что хотите удалить?', | ||
...ruRuPopconfirmLocale, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './enUS' | ||
export * from './ruRU' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { FiltersLocale } from '../interfaces' | ||
|
||
export const ruRU: FiltersLocale = { | ||
title: 'Фильтры', | ||
clear: 'Очистить все', | ||
submit: 'Применить', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './enUS' | ||
export * from './ruRU' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Locale } from '../interfaces' | ||
import { ruRU as ruRuDatePickerLocale } from '../../ui/DatePicker/locales' | ||
import { ruRU as ruRuSelectLocale } from '../../ui/Select/locales' | ||
import { ruRU as ruRuUploadLocale } from '../../ui/Upload/locales' | ||
|
||
export const ruRU: Locale = { | ||
fields: { | ||
array: { | ||
add: 'Добавить', | ||
remove: 'Удалить', | ||
}, | ||
datePicker: ruRuDatePickerLocale, | ||
select: ruRuSelectLocale, | ||
upload: ruRuUploadLocale, | ||
}, | ||
successMessage: 'Данные успешно сохранены!', | ||
serverErrorMessage: 'Произошла ошибка на сервере.', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { createContext, useContext, useMemo } from 'react' | ||
import { enUS } from './locales' | ||
import { AdmiralLocale } from './interfaces' | ||
|
||
export const defaultLocale: AdmiralLocale = enUS | ||
|
||
export const LocaleContext = createContext<AdmiralLocale>({ ...defaultLocale }) | ||
|
||
export const LocaleContextProvider: React.FC<{ value?: Partial<AdmiralLocale> }> = ({ | ||
value, | ||
children, | ||
}) => { | ||
const contextValue = useMemo( | ||
() => (value ? { ...defaultLocale, ...value } : { ...defaultLocale }), | ||
[value], | ||
) | ||
|
||
return <LocaleContext.Provider value={contextValue}>{children}</LocaleContext.Provider> | ||
} | ||
|
||
export function useLocaleProvider() { | ||
return useContext(LocaleContext) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * as admiralLocales from './locales' | ||
export * from './LocaleContext' | ||
export * from './interfaces' |
Oops, something went wrong.