Added i18next-loader to webpack

This commit is contained in:
Dylan 2022-07-17 12:12:12 +09:30
parent 5ec542143c
commit ef31851554
7 changed files with 1378 additions and 809 deletions

693
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -15,6 +15,7 @@
"author": "Ajay Bura", "author": "Ajay Bura",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alienfast/i18next-loader": "^1.1.4",
"@fontsource/inter": "^4.5.11", "@fontsource/inter": "^4.5.11",
"@fontsource/roboto": "^4.5.7", "@fontsource/roboto": "^4.5.7",
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz", "@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.8.tgz",
@ -26,11 +27,10 @@
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"flux": "^4.0.3", "flux": "^4.0.3",
"formik": "^2.2.9", "formik": "^2.2.9",
"html-react-parser": "^1.4.14", "html-react-parser": "^2.0.0",
"i18next": "^21.8.9", "i18next": "^21.8.9",
"i18next-browser-languagedetector": "^6.1.4", "i18next-browser-languagedetector": "^6.1.4",
"i18next-http-backend": "^1.4.1", "i18next-http-backend": "^1.4.1",
"html-react-parser": "^2.0.0",
"katex": "^0.15.6", "katex": "^0.15.6",
"linkify-html": "^4.0.0-beta.5", "linkify-html": "^4.0.0-beta.5",
"linkifyjs": "^4.0.0-beta.5", "linkifyjs": "^4.0.0-beta.5",

View file

@ -1,4 +1,5 @@
{ {
"translation": {
"common": { "common": {
"close": "Close", "close": "Close",
"open": "Open", "open": "Open",
@ -456,8 +457,7 @@
"ConfirmDialog": { "ConfirmDialog": {
"cancel": "Cancel" "cancel": "Cancel"
}, },
"ReusableDialog": "ReusableDialog": {
{
"close_tooltip": "Close" "close_tooltip": "Close"
}, },
"FollowingMembers": { "FollowingMembers": {
@ -466,14 +466,12 @@
"users_following_three": "<bold>{{user_one}}</bold>, <bold>{{user_two}}</bold>, and <bold>{{user_three}}</bold> are following the conversation", "users_following_three": "<bold>{{user_one}}</bold>, <bold>{{user_two}}</bold>, and <bold>{{user_three}}</bold> are following the conversation",
"users_following_other": "<bold>{{user_one}}</bold>, <bold>{{user_two}}</bold>, <bold>{{user_three}}</bold> and {{other_count}} others are following the conversation" "users_following_other": "<bold>{{user_one}}</bold>, <bold>{{user_two}}</bold>, <bold>{{user_three}}</bold> and {{other_count}} others are following the conversation"
}, },
"ImageUpload": "ImageUpload": {
{
"prompt": "Upload", "prompt": "Upload",
"cancel": "Cancel", "cancel": "Cancel",
"remove": "Remove" "remove": "Remove"
}, },
"ExportE2ERoomKeys": "ExportE2ERoomKeys": {
{
"getting_keys": "Getting keys...", "getting_keys": "Getting keys...",
"encrypting_keys": "Encrypting Keys...", "encrypting_keys": "Encrypting Keys...",
"password_does_not_match": "Password does not match.", "password_does_not_match": "Password does not match.",
@ -481,8 +479,7 @@
"export_failed": "Failed to export keys. Please try again.", "export_failed": "Failed to export keys. Please try again.",
"button_text": "Export" "button_text": "Export"
}, },
"ImportE2ERoomKeys": "ImportE2ERoomKeys": {
{
"decrypting_file": "Decrypting file...", "decrypting_file": "Decrypting file...",
"decrypting_messages": "Decrypting messages...", "decrypting_messages": "Decrypting messages...",
"import_success": "Successfully imported all keys", "import_success": "Successfully imported all keys",
@ -496,8 +493,7 @@
"play_audio": "Play audio", "play_audio": "Play audio",
"play_video": "Play video" "play_video": "Play video"
}, },
"Message": "Message": {
{
"message_deleted": "*** This message has been deleted ***", "message_deleted": "*** This message has been deleted ***",
"unable_to_load_reply": "*** Unable to load reply ***", "unable_to_load_reply": "*** Unable to load reply ***",
"unknown_user": "** Unknown user **", "unknown_user": "** Unknown user **",
@ -518,8 +514,7 @@
"delete_message_confirmation": "Are you sure that you want to delete this message?", "delete_message_confirmation": "Are you sure that you want to delete this message?",
"delete_message_button": "Delete" "delete_message_button": "Delete"
}, },
"PopupWindow": "PopupWindow": {
{
"close_tooltip": "Back" "close_tooltip": "Back"
}, },
"PowerLevelSelector": { "PowerLevelSelector": {
@ -536,22 +531,19 @@
"unpublish_alias": "Unpublish", "unpublish_alias": "Unpublish",
"delete_alias": "Delete", "delete_alias": "Delete",
"main_alias": "Main", "main_alias": "Main",
"publish_to_room_directory": "publish_to_room_directory": {
{
"title": "Publish to room directory", "title": "Publish to room directory",
"publish_room_message": "Publish this room to the {{homeserver}} publish directory?", "publish_room_message": "Publish this room to the {{homeserver}} publish directory?",
"publish_space_message": "Publish this space to the {{homeserver}} publish directory?" "publish_space_message": "Publish this space to the {{homeserver}} publish directory?"
}, },
"published_addresses": "published_addresses": {
{
"title": "Published addresses", "title": "Published addresses",
"none": "No published addresses", "none": "No published addresses",
"no_main_address": "No main address (select one from below)", "no_main_address": "No main address (select one from below)",
"message_room": "Published addresses can be used by anyone on any server to join your room. To publish an address, it needs to be set as a local address first.", "message_room": "Published addresses can be used by anyone on any server to join your room. To publish an address, it needs to be set as a local address first.",
"message_space": "Published addresses can be used by anyone on any server to join your space. To publish an address, it needs to be set as a local address first." "message_space": "Published addresses can be used by anyone on any server to join your space. To publish an address, it needs to be set as a local address first."
}, },
"local_addresses": "local_addresses": {
{
"title": "Local addresses", "title": "Local addresses",
"none": "No local addresses", "none": "No local addresses",
"message_room": "Set local addresses for this room so users can find this room through your homeserver.", "message_room": "Set local addresses for this room so users can find this room through your homeserver.",
@ -562,7 +554,6 @@
"placeholder_space": "my_space_address", "placeholder_space": "my_space_address",
"hide": "Hide local addresses", "hide": "Hide local addresses",
"view": "View local addresses" "view": "View local addresses"
} }
}, },
"RoomEncryption": { "RoomEncryption": {
@ -573,7 +564,6 @@
"enable_encryption_prompt": "Enable Encryption", "enable_encryption_prompt": "Enable Encryption",
"enable_encryption_button": "Enable", "enable_encryption_button": "Enable",
"continue_button": "Continue" "continue_button": "Continue"
}, },
"RoomHistoryVisibility": { "RoomHistoryVisibility": {
"world_readable": "Anyone (including guests)", "world_readable": "Anyone (including guests)",
@ -594,8 +584,7 @@
"banned": "Banned", "banned": "Banned",
"search_placeholder": "Search for name" "search_placeholder": "Search for name"
}, },
"RoomNotification": "RoomNotification": {
{
"default": "Global", "default": "Global",
"all_messages": "All messages", "all_messages": "All messages",
"mentions_and_keywords": "Mentions & Keywords", "mentions_and_keywords": "Mentions & Keywords",
@ -612,8 +601,7 @@
"notifications_heading": "Notifications", "notifications_heading": "Notifications",
"invite": "Invite" "invite": "Invite"
}, },
"RoomPermissions": "RoomPermissions": {
{
"default_role": { "default_role": {
"name": "Default role", "name": "Default role",
"description": "Set default role for all members" "description": "Set default role for all members"
@ -698,8 +686,7 @@
"name": "Modify widgets", "name": "Modify widgets",
"description": "Set minimum power level to modify room widgets" "description": "Set minimum power level to modify room widgets"
}, },
"groups": "groups": {
{
"general": "General permissions", "general": "General permissions",
"manage_members": "Manage members permissions", "manage_members": "Manage members permissions",
"room": "Room profile permissions", "room": "Room profile permissions",
@ -774,3 +761,4 @@
} }
} }
} }
}

1
public/locales/index.js Normal file
View file

@ -0,0 +1 @@
//root pointer

View file

@ -1,11 +1,9 @@
import i18n from 'i18next'; import i18n from 'i18next';
import { initReactI18next } from 'react-i18next'; import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector'; import LanguageDetector from 'i18next-browser-languagedetector';
import Backend from 'i18next-http-backend' import resources from '../../public/locales';
i18n i18n
.use(Backend)
// detect user language
// learn more: https://github.com/i18next/i18next-browser-languageDetector // learn more: https://github.com/i18next/i18next-browser-languageDetector
.use(LanguageDetector) .use(LanguageDetector)
// pass the i18n instance to react-i18next. // pass the i18n instance to react-i18next.
@ -13,10 +11,12 @@ i18n
// init i18next // init i18next
// for all options read: https://www.i18next.com/overview/configuration-options // for all options read: https://www.i18next.com/overview/configuration-options
.init({ .init({
resources,
debug: true, debug: true,
fallbackLng: 'en',
interpolation: { interpolation: {
escapeValue: false, // not needed for react as it escapes by default escapeValue: false, // not needed for react as it escapes by default
} },
}); });
export default i18n; export default i18n;

View file

@ -47,6 +47,10 @@ module.exports = {
{ {
test: /\.svg$/, test: /\.svg$/,
type: 'asset/inline', type: 'asset/inline',
},
{
test: /locales/,
loader: '@alienfast/i18next-loader'
} }
], ],
}, },

View file

@ -21,7 +21,8 @@ module.exports = merge(common, {
'css-loader', 'css-loader',
'sass-loader', 'sass-loader',
], ],
},
}
], ],
}, },
}); });