kopia lustrzana https://github.com/Tldraw/Tldraw
Simplify RTL
rodzic
e3ceb270e7
commit
4a84b3482c
|
@ -1,8 +1,7 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"locale": "ar",
|
"locale": "ar",
|
||||||
"label": "عربي",
|
"label": "عربي"
|
||||||
"isRTL": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"locale": "ca",
|
"locale": "ca",
|
||||||
|
@ -30,8 +29,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"locale": "fa",
|
"locale": "fa",
|
||||||
"label": "فارسی",
|
"label": "فارسی"
|
||||||
"isRTL": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"locale": "fi",
|
"locale": "fi",
|
||||||
|
@ -47,8 +45,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"locale": "he",
|
"locale": "he",
|
||||||
"label": "עברית",
|
"label": "עברית"
|
||||||
"isRTL": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"locale": "hr",
|
"locale": "hr",
|
||||||
|
@ -68,8 +65,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"locale": "ku",
|
"locale": "ku",
|
||||||
"label": "کوردی",
|
"label": "کوردی"
|
||||||
"isRTL": true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"locale": "hi-in",
|
"locale": "hi-in",
|
||||||
|
|
|
@ -2408,8 +2408,8 @@ export type TLUiToolsProviderProps = {
|
||||||
export type TLUiTranslation = {
|
export type TLUiTranslation = {
|
||||||
readonly locale: string;
|
readonly locale: string;
|
||||||
readonly label: string;
|
readonly label: string;
|
||||||
readonly isRTL?: boolean;
|
|
||||||
readonly messages: Record<TLUiTranslationKey, string>;
|
readonly messages: Record<TLUiTranslationKey, string>;
|
||||||
|
readonly dir: 'ltr' | 'rtl';
|
||||||
};
|
};
|
||||||
|
|
||||||
// @public (undocumented)
|
// @public (undocumented)
|
||||||
|
|
|
@ -26610,7 +26610,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
"text": "{\n readonly locale: string;\n readonly label: string;\n readonly isRTL?: boolean;\n readonly messages: "
|
"text": "{\n readonly locale: string;\n readonly label: string;\n readonly messages: "
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "Reference",
|
"kind": "Reference",
|
||||||
|
@ -26628,7 +26628,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
"text": ", string>;\n}"
|
"text": ", string>;\n readonly dir: 'ltr' | 'rtl';\n}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
|
|
|
@ -385,7 +385,7 @@ function useNoteKeydownHandler(id: TLShapeId) {
|
||||||
// Based on the inputs, calculate the offset to the next note
|
// Based on the inputs, calculate the offset to the next note
|
||||||
// tab controls x axis (shift inverts direction set by RTL)
|
// tab controls x axis (shift inverts direction set by RTL)
|
||||||
// cmd enter is the y axis (shift inverts direction)
|
// cmd enter is the y axis (shift inverts direction)
|
||||||
const isRTL = !!(translation.isRTL || isRightToLeftLanguage(shape.props.text))
|
const isRTL = !!(translation.dir === 'rtl' || isRightToLeftLanguage(shape.props.text))
|
||||||
|
|
||||||
const offsetLength =
|
const offsetLength =
|
||||||
NOTE_SIZE +
|
NOTE_SIZE +
|
||||||
|
@ -409,6 +409,6 @@ function useNoteKeydownHandler(id: TLShapeId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[id, editor, translation.isRTL]
|
[id, editor, translation.dir]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,18 +10,21 @@ import { DEFAULT_TRANSLATION } from './defaultTranslation'
|
||||||
|
|
||||||
/* ----------------- (do not change) ---------------- */
|
/* ----------------- (do not change) ---------------- */
|
||||||
|
|
||||||
|
export const RTL_LANGUAGES = new Set(['ar', 'fa', 'he', 'ur', 'ku'])
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
export type TLUiTranslation = {
|
export type TLUiTranslation = {
|
||||||
readonly locale: string
|
readonly locale: string
|
||||||
readonly label: string
|
readonly label: string
|
||||||
readonly isRTL?: boolean
|
|
||||||
readonly messages: Record<TLUiTranslationKey, string>
|
readonly messages: Record<TLUiTranslationKey, string>
|
||||||
|
readonly dir: 'rtl' | 'ltr'
|
||||||
}
|
}
|
||||||
|
|
||||||
const EN_TRANSLATION: TLUiTranslation = {
|
const EN_TRANSLATION: TLUiTranslation = {
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
label: 'English',
|
label: 'English',
|
||||||
messages: DEFAULT_TRANSLATION as TLUiTranslation['messages'],
|
messages: DEFAULT_TRANSLATION as TLUiTranslation['messages'],
|
||||||
|
dir: 'ltr',
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
|
@ -70,7 +73,7 @@ export async function fetchTranslation(
|
||||||
return {
|
return {
|
||||||
locale,
|
locale,
|
||||||
label: language.label,
|
label: language.label,
|
||||||
isRTL: 'isRTL' in language ? language.isRTL : false,
|
dir: RTL_LANGUAGES.has(language.locale) ? 'rtl' : 'ltr',
|
||||||
messages: { ...EN_TRANSLATION.messages, ...messages },
|
messages: { ...EN_TRANSLATION.messages, ...messages },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ export const TranslationProvider = track(function TranslationProvider({
|
||||||
return {
|
return {
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
label: 'English',
|
label: 'English',
|
||||||
|
dir: 'ltr',
|
||||||
messages: { ...DEFAULT_TRANSLATION, ...overrides['en'] },
|
messages: { ...DEFAULT_TRANSLATION, ...overrides['en'] },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +56,7 @@ export const TranslationProvider = track(function TranslationProvider({
|
||||||
return {
|
return {
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
label: 'English',
|
label: 'English',
|
||||||
|
dir: 'ltr',
|
||||||
messages: DEFAULT_TRANSLATION,
|
messages: DEFAULT_TRANSLATION,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -636,19 +636,15 @@ export const LANGUAGES: readonly [{
|
||||||
}, {
|
}, {
|
||||||
readonly locale: "he";
|
readonly locale: "he";
|
||||||
readonly label: "עברית";
|
readonly label: "עברית";
|
||||||
readonly isRTL: true;
|
|
||||||
}, {
|
}, {
|
||||||
readonly locale: "ar";
|
readonly locale: "ar";
|
||||||
readonly label: "عربي";
|
readonly label: "عربي";
|
||||||
readonly isRTL: true;
|
|
||||||
}, {
|
}, {
|
||||||
readonly locale: "fa";
|
readonly locale: "fa";
|
||||||
readonly label: "فارسی";
|
readonly label: "فارسی";
|
||||||
readonly isRTL: true;
|
|
||||||
}, {
|
}, {
|
||||||
readonly locale: "ku";
|
readonly locale: "ku";
|
||||||
readonly label: "کوردی";
|
readonly label: "کوردی";
|
||||||
readonly isRTL: true;
|
|
||||||
}, {
|
}, {
|
||||||
readonly locale: "ne";
|
readonly locale: "ne";
|
||||||
readonly label: "नेपाली";
|
readonly label: "नेपाली";
|
||||||
|
|
|
@ -2750,7 +2750,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kind": "Content",
|
"kind": "Content",
|
||||||
"text": "readonly [{\n readonly locale: \"ca\";\n readonly label: \"Català\";\n}, {\n readonly locale: \"cs\";\n readonly label: \"Čeština\";\n}, {\n readonly locale: \"da\";\n readonly label: \"Danish\";\n}, {\n readonly locale: \"de\";\n readonly label: \"Deutsch\";\n}, {\n readonly locale: \"en\";\n readonly label: \"English\";\n}, {\n readonly locale: \"es\";\n readonly label: \"Español\";\n}, {\n readonly locale: \"fr\";\n readonly label: \"Français\";\n}, {\n readonly locale: \"gl\";\n readonly label: \"Galego\";\n}, {\n readonly locale: \"hr\";\n readonly label: \"Hrvatski\";\n}, {\n readonly locale: \"it\";\n readonly label: \"Italiano\";\n}, {\n readonly locale: \"hu\";\n readonly label: \"Magyar\";\n}, {\n readonly locale: \"no\";\n readonly label: \"Norwegian\";\n}, {\n readonly locale: \"pl\";\n readonly label: \"Polski\";\n}, {\n readonly locale: \"pt-br\";\n readonly label: \"Português - Brasil\";\n}, {\n readonly locale: \"pt-pt\";\n readonly label: \"Português - Europeu\";\n}, {\n readonly locale: \"ro\";\n readonly label: \"Română\";\n}, {\n readonly locale: \"ru\";\n readonly label: \"Russian\";\n}, {\n readonly locale: \"sl\";\n readonly label: \"Slovenščina\";\n}, {\n readonly locale: \"fi\";\n readonly label: \"Suomi\";\n}, {\n readonly locale: \"sv\";\n readonly label: \"Svenska\";\n}, {\n readonly locale: \"vi\";\n readonly label: \"Tiếng Việt\";\n}, {\n readonly locale: \"tr\";\n readonly label: \"Türkçe\";\n}, {\n readonly locale: \"uk\";\n readonly label: \"Ukrainian\";\n}, {\n readonly locale: \"he\";\n readonly label: \"עברית\";\n readonly isRTL: true;\n}, {\n readonly locale: \"ar\";\n readonly label: \"عربي\";\n readonly isRTL: true;\n}, {\n readonly locale: \"fa\";\n readonly label: \"فارسی\";\n readonly isRTL: true;\n}, {\n readonly locale: \"ku\";\n readonly label: \"کوردی\";\n readonly isRTL: true;\n}, {\n readonly locale: \"ne\";\n readonly label: \"नेपाली\";\n}, {\n readonly locale: \"hi-in\";\n readonly label: \"हिन्दी\";\n}, {\n readonly locale: \"te\";\n readonly label: \"తెలుగు\";\n}, {\n readonly locale: \"th\";\n readonly label: \"ภาษาไทย\";\n}, {\n readonly locale: \"my\";\n readonly label: \"မြန်မာစာ\";\n}, {\n readonly locale: \"ko-kr\";\n readonly label: \"한국어\";\n}, {\n readonly locale: \"ja\";\n readonly label: \"日本語\";\n}, {\n readonly locale: \"zh-cn\";\n readonly label: \"简体中文\";\n}, {\n readonly locale: \"zh-tw\";\n readonly label: \"繁體中文 (台灣)\";\n}]"
|
"text": "readonly [{\n readonly locale: \"ca\";\n readonly label: \"Català\";\n}, {\n readonly locale: \"cs\";\n readonly label: \"Čeština\";\n}, {\n readonly locale: \"da\";\n readonly label: \"Danish\";\n}, {\n readonly locale: \"de\";\n readonly label: \"Deutsch\";\n}, {\n readonly locale: \"en\";\n readonly label: \"English\";\n}, {\n readonly locale: \"es\";\n readonly label: \"Español\";\n}, {\n readonly locale: \"fr\";\n readonly label: \"Français\";\n}, {\n readonly locale: \"gl\";\n readonly label: \"Galego\";\n}, {\n readonly locale: \"hr\";\n readonly label: \"Hrvatski\";\n}, {\n readonly locale: \"it\";\n readonly label: \"Italiano\";\n}, {\n readonly locale: \"hu\";\n readonly label: \"Magyar\";\n}, {\n readonly locale: \"no\";\n readonly label: \"Norwegian\";\n}, {\n readonly locale: \"pl\";\n readonly label: \"Polski\";\n}, {\n readonly locale: \"pt-br\";\n readonly label: \"Português - Brasil\";\n}, {\n readonly locale: \"pt-pt\";\n readonly label: \"Português - Europeu\";\n}, {\n readonly locale: \"ro\";\n readonly label: \"Română\";\n}, {\n readonly locale: \"ru\";\n readonly label: \"Russian\";\n}, {\n readonly locale: \"sl\";\n readonly label: \"Slovenščina\";\n}, {\n readonly locale: \"fi\";\n readonly label: \"Suomi\";\n}, {\n readonly locale: \"sv\";\n readonly label: \"Svenska\";\n}, {\n readonly locale: \"vi\";\n readonly label: \"Tiếng Việt\";\n}, {\n readonly locale: \"tr\";\n readonly label: \"Türkçe\";\n}, {\n readonly locale: \"uk\";\n readonly label: \"Ukrainian\";\n}, {\n readonly locale: \"he\";\n readonly label: \"עברית\";\n}, {\n readonly locale: \"ar\";\n readonly label: \"عربي\";\n}, {\n readonly locale: \"fa\";\n readonly label: \"فارسی\";\n}, {\n readonly locale: \"ku\";\n readonly label: \"کوردی\";\n}, {\n readonly locale: \"ne\";\n readonly label: \"नेपाली\";\n}, {\n readonly locale: \"hi-in\";\n readonly label: \"हिन्दी\";\n}, {\n readonly locale: \"te\";\n readonly label: \"తెలుగు\";\n}, {\n readonly locale: \"th\";\n readonly label: \"ภาษาไทย\";\n}, {\n readonly locale: \"my\";\n readonly label: \"မြန်မာစာ\";\n}, {\n readonly locale: \"ko-kr\";\n readonly label: \"한국어\";\n}, {\n readonly locale: \"ja\";\n readonly label: \"日本語\";\n}, {\n readonly locale: \"zh-cn\";\n readonly label: \"简体中文\";\n}, {\n readonly locale: \"zh-tw\";\n readonly label: \"繁體中文 (台灣)\";\n}]"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"fileUrlPath": "packages/tlschema/src/translations/languages.ts",
|
"fileUrlPath": "packages/tlschema/src/translations/languages.ts",
|
||||||
|
|
|
@ -26,10 +26,10 @@ export const LANGUAGES = [
|
||||||
{ locale: 'vi', label: 'Tiếng Việt' },
|
{ locale: 'vi', label: 'Tiếng Việt' },
|
||||||
{ locale: 'tr', label: 'Türkçe' },
|
{ locale: 'tr', label: 'Türkçe' },
|
||||||
{ locale: 'uk', label: 'Ukrainian' },
|
{ locale: 'uk', label: 'Ukrainian' },
|
||||||
{ locale: 'he', label: 'עברית', isRTL: true },
|
{ locale: 'he', label: 'עברית' },
|
||||||
{ locale: 'ar', label: 'عربي', isRTL: true },
|
{ locale: 'ar', label: 'عربي' },
|
||||||
{ locale: 'fa', label: 'فارسی', isRTL: true },
|
{ locale: 'fa', label: 'فارسی' },
|
||||||
{ locale: 'ku', label: 'کوردی', isRTL: true },
|
{ locale: 'ku', label: 'کوردی' },
|
||||||
{ locale: 'ne', label: 'नेपाली' },
|
{ locale: 'ne', label: 'नेपाली' },
|
||||||
{ locale: 'hi-in', label: 'हिन्दी' },
|
{ locale: 'hi-in', label: 'हिन्दी' },
|
||||||
{ locale: 'te', label: 'తెలుగు' },
|
{ locale: 'te', label: 'తెలుగు' },
|
||||||
|
|
Ładowanie…
Reference in New Issue