Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

i18n-rtl

БесплатноБез исполняемых скриптовНе проверен

MUI internationalization, RTL support, locale customization, and bidirectional text

TheLobbiот TheLobbi★ 22 звезды на GitHub

Об этом скилле

MUI Internationalization & RTL Support

1. RTL Setup

Set the document direction and configure the MUI theme:

// index.html — set dir on <html>
<html dir="rtl" lang="ar">

// theme.ts
import { createTheme } from '@mui/material/styles';

const rtlTheme = createTheme({
  direction: 'rtl',
});

Install the Emotion RTL plugin for automatic style flipping:

npm install stylis-plugin-rtl stylis

Wrap the app with the RTL-aware cache provider:

import { CacheProvider } from '@emotion/react';
import createCache from '@emotion/cache';
import { ThemeProvider } from '@mui/material/styles';
import rtlPlugin from 'stylis-plugin-rtl';
import { prefixer } from 'stylis';

const cacheRtl = createCache({
  key: 'muirtl',
  stylisPlugins: [prefixer, rtlPlugin],
});

function App() {
  return (
    <CacheProvider value={cacheRtl}>
      <ThemeProvider theme={rtlTheme}>
        {/* All MUI components now render RTL */}
        <MyApplication />
      </ThemeProvider>
    </CacheProvider>
  );
}

2. Emotion RTL Cache

The RTL cache intercepts all Emotion-generated styles and flips directional properties (margin-left becomes margin-right, padding-left becomes padding-right, etc.).

import createCache from '@emotion/cache';
import rtlPlugin from 'stylis-plugin-rtl';
import { prefixer } from 'stylis';

// RTL cache — use for Arabic, Hebrew, Persian, Urdu
const rtlCache = createCache({
  key: 'muirtl',
  stylisPlugins: [prefixer, rtlPlugin],
});

// LTR cache — use for English, French, German, etc.
const ltrCache = createCache({
  key: 'muiltr',
  stylisPlugins: [prefixer],
});

Key points:

  • The key must be unique per cache instance (e.g. 'muirtl' vs 'muiltr').
  • prefixer adds vendor prefixes and should always be included.
  • rtlPlugin must come after prefixer in the array.

3. Dynamic Direction Switching

Toggle between LTR and RTL at runtime using React state:

import { useState, useMemo } from 'react';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { CacheProvider } from '@emotion/react';
import createCache from '@emotion/cache';
import rtlPlugin from 'stylis-plugin-rtl';
import { prefixer } from 'stylis';
import CssBaseline from '@mui/material/CssBaseline';
import IconButton from '@mui/material/IconButton';
import FormatTextdirectionLToRIcon from '@mui/icons-material/FormatTextdirectionLToR';
import FormatTextdirectionRToLIcon from '@mui/icons-material/FormatTextdirectionRToL';

const rtlCache = createCache({
  key: 'muirtl',
  stylisPlugins: [prefixer, rtlPlugin],
});

const ltrCache = createCache({
  key: 'muiltr',
  stylisPlugins: [prefixer],
});

function App() {
  const [direction, setDirection] = useState<'ltr' | 'rtl'>('ltr');

  const theme = useMemo(
    () => createTheme({ direction }),
    [direction],
  );

  const toggleDirection = () => {
    const newDir = direction === 'ltr' ? 'rtl' : 'ltr';
    setDirection(newDir);
    document.dir = newDir; // sync <html> dir attribute
  };

  return (
    <CacheProvider value={direction === 'rtl' ? rtlCache : ltrCache}>
      <ThemeProvider theme={theme}>
        <CssBaseline />
        <IconButton onClick={toggleDirection}>
          {direction === 'ltr'
            ? <FormatTextdirectionRToLIcon />
            : <FormatTextdirectionLToRIcon />}
        </IconButton>
        <MyApplication />
      </ThemeProvider>
    </CacheProvider>
  );
}

Important: always sync document.dir with the theme direction so native browser layout matches MUI.

4. Component Localization

MUI ships built-in locale strings for 50+ languages. Pass a locale object as the second argument to createTheme:

import { createTheme } from '@mui/material/styles';
import { deDE } from '@mui/material/locale';

// German locale — translates MUI component strings
// (e.g. TablePagination "Rows per page" -> "Zeilen pro Seite")
const theme = createTheme(
  {
    palette: {
      primary: { main: '#1976d2' },
    },
  },
  deDE, // locale object as second argument
);

Common locale imports:

import { enUS } from '@mui/material/locale'; // English (default)
import { frFR } from '@mui/material/locale'; // French
import { esES } from '@mui/material/locale'; // Spanish
import { jaJP } from '@mui/material/locale'; // Japanese
import { zhCN } from '@mui/material/locale'; // Chinese (Simplified)
import { arSA } from '@mui/material/locale'; // Arabic (Saudi Arabia)
import { heIL } from '@mui/material/locale'; // Hebrew (Israel)
import { koKR } from '@mui/material/locale'; // Korean
import { ptBR } from '@mui/material/locale'; // Portuguese (Brazil)
import { trTR } from '@mui/material/locale'; // Turkish

For RTL languages, combine direction with locale:

import { arSA } from '@mui/material/locale';

const arabicTheme = createTheme(
  {
    direction: 'rtl',
    typography: {
      fontFamily: '"Noto Sans Arabic", "Roboto", sans-serif',
    },
  },
  arSA,
);

5. MUI

Полный SKILL.md на GitHub

Установить i18n-rtl в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Glob
Grep
Write
Edit

FAQ

Что делает скилл i18n-rtl?

MUI internationalization, RTL support, locale customization, and bidirectional text

Как установить скилл i18n-rtl?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл i18n-rtl запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить i18n-rtl с