Skip to content

Commit ab9526e

Browse files
committed
refactor(i18n): use consistent locale variable names and full language codes
1 parent 42356f2 commit ab9526e

5 files changed

Lines changed: 69 additions & 43 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ type File = {
116116
| `height` | string \| number | The height of the component `default: 600px`. Can be a string (e.g., `'100%'`, `'10rem'`) or a number (in pixels). |
117117
| `initialPath` | string | The path of the directory to be loaded initially e.g. `/Documents`. This should be the path of a folder which is included in `files` array. Default value is `""` |
118118
| `isLoading` | boolean | A boolean state indicating whether the application is currently performing an operation, such as creating, renaming, or deleting a file/folder. Displays a loading state if set `true`. |
119-
| `language` | string | A language code used for translations (e.g., `"en"`, `"fr"`, `"tr"`). Defaults to `"en"` for English. Allows the user to set the desired translation language manually. |
119+
| `language` | string | A language code used for translations (e.g., `"en-US"`, `"fr-FR"`, `"tr-TR"`). Defaults to `"en-US"` for English. Allows the user to set the desired translation language manually. <br><br>**Available languages:** <br> 🇸🇦 `ar-SA` (Arabic, Saudi Arabia) <br> 🇩🇪 `de-DE` (German, Germany) <br> 🇺🇸 `en-US` (English, United States) <br> 🇪🇸 `es-ES` (Spanish, Spain) <br> 🇫🇷 `fr-FR` (French, France) <br> 🇮🇱 `he-IL` (Hebrew, Israel) <br> 🇮🇳 `hi-IN` (Hindi, India) <br> 🇮🇹 `it-IT` (Italian, Italy) <br> 🇯🇵 `ja-JP` (Japanese, Japan) <br> 🇰🇷 `ko-KR` (Korean, South Korea) <br> 🇧🇷 `pt-BR` (Portuguese, Brazil) <br> 🇵🇹 `pt-PT` (Portuguese, Portugal) <br> 🇷🇺 `ru-RU` (Russian, Russia) <br> 🇹🇷 `tr-TR` (Turkish, Turkey) <br> 🇺🇦 `uk-UA` (Ukrainian, Ukraine) <br> 🇵🇰 `ur-UR` (Urdu, Pakistan) <br> 🇻🇳 `vi-VN` (Vietnamese, Vietnam) <br> 🇨🇳 `zh-CN` (Chinese, Simplified) <br> 🇵🇱 `pl-PL` (Polish, Poland) |
120120
| `layout` | "list" \| "grid" | Specifies the default layout style for the file manager. Can be either "list" or "grid". Default value is "grid". |
121121
| `maxFileSize` | number | For limiting the maximum upload file size in bytes. |
122122
| `onCopy` | (files: Array<[File](#-file-structure)>) => void | (Optional) A callback function triggered when one or more files or folders are copied providing copied files as an argument. Use this function to perform custom actions on copy event. |

frontend/CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
# [1.30.0](https://github.com/Saifullah-dev/react-file-manager/compare/v1.27.0...v1.30.0) (2025-10-07)
2+
3+
### 🧩 Internationalization (i18n)
4+
5+
- **Added:** Portuguese (Portugal) locale support (`pt-PT`)
6+
([#226](https://github.com/Saifullah-dev/react-file-manager/pull/226))
7+
8+
- **Refactored:** All locale imports and resource keys now use **consistent full locale codes**
9+
(e.g., `en-US`, `fr-FR`, `ar-SA`, `pt-BR`, `pt-PT`, etc.) for better clarity and alignment with
10+
[i18next language conventions](https://www.i18next.com/overview/configuration-options#languages-namespace).
11+
12+
### ⚠️ Breaking Changes
13+
14+
- Language codes used in `i18n` initialization have been updated from short forms like `"en"`, `"fr"`, `"pt"`
15+
to **full locale codes** such as `"en-US"`, `"fr-FR"`, `"pt-BR"`, `"pt-PT"`, etc.
16+
- If your application sets or changes languages manually, please update your code accordingly:
17+
18+
```js
19+
// Before
20+
<FileManager language="pt" files={files} />;
21+
22+
// After
23+
<FileManager language="pt-PT" files={files} />;
24+
```
25+
A full list of supported locale keys is available in the documentation.
26+
127
# [1.27.0](https://github.com/Saifullah-dev/react-file-manager/compare/v1.26.3...v1.27.0) (2025-09-12)
228

329
### ✨ Features

frontend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ type File = {
113113
| `height` | string \| number | The height of the component `default: 600px`. Can be a string (e.g., `'100%'`, `'10rem'`) or a number (in pixels). |
114114
| `initialPath` | string | The path of the directory to be loaded initially e.g. `/Documents`. This should be the path of a folder which is included in `files` array. Default value is `""` |
115115
| `isLoading` | boolean | A boolean state indicating whether the application is currently performing an operation, such as creating, renaming, or deleting a file/folder. Displays a loading state if set `true`. |
116-
| `language` | string | A language code used for translations (e.g., `"en"`, `"fr"`, `"tr"`). Defaults to `"en"` for English. Allows the user to set the desired translation language manually. |
116+
| `language` | string | A language code used for translations (e.g., `"en-US"`, `"fr-FR"`, `"tr-TR"`). Defaults to `"en-US"` for English. Allows the user to set the desired translation language manually. <br><br>**Available languages:** <br> 🇸🇦 `ar-SA` (Arabic, Saudi Arabia) <br> 🇩🇪 `de-DE` (German, Germany) <br> 🇺🇸 `en-US` (English, United States) <br> 🇪🇸 `es-ES` (Spanish, Spain) <br> 🇫🇷 `fr-FR` (French, France) <br> 🇮🇱 `he-IL` (Hebrew, Israel) <br> 🇮🇳 `hi-IN` (Hindi, India) <br> 🇮🇹 `it-IT` (Italian, Italy) <br> 🇯🇵 `ja-JP` (Japanese, Japan) <br> 🇰🇷 `ko-KR` (Korean, South Korea) <br> 🇧🇷 `pt-BR` (Portuguese, Brazil) <br> 🇵🇹 `pt-PT` (Portuguese, Portugal) <br> 🇷🇺 `ru-RU` (Russian, Russia) <br> 🇹🇷 `tr-TR` (Turkish, Turkey) <br> 🇺🇦 `uk-UA` (Ukrainian, Ukraine) <br> 🇵🇰 `ur-UR` (Urdu, Pakistan) <br> 🇻🇳 `vi-VN` (Vietnamese, Vietnam) <br> 🇨🇳 `zh-CN` (Chinese, Simplified) <br> 🇵🇱 `pl-PL` (Polish, Poland) |
117117
| `layout` | "list" \| "grid" | Specifies the default layout style for the file manager. Can be either "list" or "grid". Default value is "grid". |
118118
| `maxFileSize` | number | For limiting the maximum upload file size in bytes. |
119119
| `onCopy` | (files: Array<[File](#-file-structure)>) => void | (Optional) A callback function triggered when one or more files or folders are copied providing copied files as an argument. Use this function to perform custom actions on copy event. |

frontend/src/FileManager/FileManager.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const FileManager = ({
4949
filePreviewComponent,
5050
primaryColor = "#6155b4",
5151
fontFamily = "Nunito Sans, sans-serif",
52-
language = "en",
52+
language = "en-US",
5353
permissions: userPermissions = {},
5454
collapsibleNav = false,
5555
defaultNavExpanded = true,

frontend/src/i18n.js

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
11
import i18n from "i18next";
2-
import ar from "./locales/ar-SA.json";
3-
import de from "./locales/de-DE.json";
4-
import en from "./locales/en-US.json";
5-
import es from "./locales/es-ES.json";
6-
import fr from "./locales/fr-FR.json";
7-
import he from "./locales/he-IL.json";
8-
import hi from "./locales/hi-IN.json";
9-
import it from "./locales/it-IT.json";
10-
import ja from "./locales/ja-JP.json";
11-
import ko from "./locales/ko-KR.json";
12-
import pt from "./locales/pt-BR.json";
13-
import ptpt from "./locales/pt-PT.json";
14-
import ru from "./locales/ru-RU.json";
15-
import tr from "./locales/tr-TR.json";
16-
import uk from "./locales/uk-UA.json";
17-
import ur from "./locales/ur-UR.json";
18-
import vi from "./locales/vi-VN.json";
19-
import zh from "./locales/zh-CN.json";
20-
import pl from "./locales/pl-PL.json";
2+
import arSA from "./locales/ar-SA.json";
3+
import deDE from "./locales/de-DE.json";
4+
import enUS from "./locales/en-US.json";
5+
import esES from "./locales/es-ES.json";
6+
import frFR from "./locales/fr-FR.json";
7+
import heIL from "./locales/he-IL.json";
8+
import hiIN from "./locales/hi-IN.json";
9+
import itIT from "./locales/it-IT.json";
10+
import jaJP from "./locales/ja-JP.json";
11+
import koKR from "./locales/ko-KR.json";
12+
import ptBR from "./locales/pt-BR.json";
13+
import ptPT from "./locales/pt-PT.json";
14+
import ruRU from "./locales/ru-RU.json";
15+
import trTR from "./locales/tr-TR.json";
16+
import ukUA from "./locales/uk-UA.json";
17+
import urUR from "./locales/ur-UR.json";
18+
import viVN from "./locales/vi-VN.json";
19+
import zhCN from "./locales/zh-CN.json";
20+
import plPL from "./locales/pl-PL.json";
2121

2222
const resources = {
23-
ar: { translation: ar },
24-
de: { translation: de },
25-
en: { translation: en },
26-
es: { translation: es },
27-
fr: { translation: fr },
28-
he: { translation: he },
29-
hi: { translation: hi },
30-
it: { translation: it },
31-
ja: { translation: ja },
32-
ko: { translation: ko },
33-
pt: { translation: pt },
34-
ptpt: { translation: ptpt },
35-
ru: { translation: ru },
36-
tr: { translation: tr },
37-
uk: { translation: uk },
38-
ur: { translation: ur },
39-
vi: { translation: vi },
40-
zh: { translation: zh },
41-
pl: { translation: pl },
23+
"ar-SA": { translation: arSA },
24+
"de-DE": { translation: deDE },
25+
"en-US": { translation: enUS },
26+
"es-ES": { translation: esES },
27+
"fr-FR": { translation: frFR },
28+
"he-IL": { translation: heIL },
29+
"hi-IN": { translation: hiIN },
30+
"it-IT": { translation: itIT },
31+
"ja-JP": { translation: jaJP },
32+
"ko-KR": { translation: koKR },
33+
"pt-BR": { translation: ptBR },
34+
"pt-PT": { translation: ptPT },
35+
"ru-RU": { translation: ruRU },
36+
"tr-TR": { translation: trTR },
37+
"uk-UA": { translation: ukUA },
38+
"ur-UR": { translation: urUR },
39+
"vi-VN": { translation: viVN },
40+
"zh-CN": { translation: zhCN },
41+
"pl-PL": { translation: plPL },
4242
};
4343

44-
export const initI18n = (lng = "en") => {
44+
export const initI18n = (lng = "en-US") => {
4545
if (!i18n.isInitialized) {
4646
i18n.init({
4747
resources,
4848
lng,
49-
fallbackLng: "en",
49+
fallbackLng: "en-US",
5050
interpolation: {
5151
escapeValue: false,
5252
},

0 commit comments

Comments
 (0)