Removing i18n from the Template
This guide provides steps to remove i18n (internationalization) from your project.
We recommend you to start your project with starter-kit version if you don't need i18n feature. If you are using full-version and you want to remove i18n feature, then this docs is for you.
Please be aware that our template supports Right-to-Left (RTL) languages like Arabic based on the language settings, automatically applying RTL formatting when an RTL language is selected. For languages like English, it uses Left-to-Right (LTR) formatting.
If you remove the internationalization (i18n) feature, this automatic RTL support will be disabled, and the template will not switch between RTL and LTR layouts based on the language.
Step 1: Uninstall i18n Packages
First, uninstall the packages associated with i18n. These packages handle language matching and format negotiation:
@formatjs/intl-localematcher@types/negotiatornegotiator
Run the appropriate command in your project's root directory based on your package manager:
- pnpm
- yarn
- npm
pnpm uninstall @formatjs/intl-localematcher @types/negotiator negotiator
yarn uninstall @formatjs/intl-localematcher @types/negotiator negotiator
npm uninstall @formatjs/intl-localematcher @types/negotiator negotiator
Step 2: Reorganize Content
Move all content from the language-specific directories [lang] folder to the main app folder:
- Transfer all files and folders from
[lang]to the rootappfolder. - After moving the content, ensure that all links and references in your project are updated to reflect the new locations.
- Delete the
[lang]folder.
Step 3: Additional Modifications
Common Changes
-
Replace the
getLocalizedUrlfunction with the actual URL in the whole project like below:- getLocalizedUrl('/your-url', locale as Locale) or getLocalizedUrl('/your-url', lang)
+ '/your-url'
Layout and Navigation Changes:
-
Go to the
src/components/layout/vertical/Navigation.tsxfile and Remove thedictionary: Awaited<ReturnType<typeof getDictionary>>from thePropsanddictionary={dictionary}from the<VerticalMenu>component. -
Go to the
src/components/layout/vertical/VerticalMenu.tsxfile and make the following changes.-
Remove the
{ dictionary }: { dictionary: Awaited<ReturnType<typeof getDictionary>> }from thepropsparameter of theVerticalMenufunction. -
Replace the
labelandhreffrom SubMenu, MenuItem and MenuSection in the whole file as below:<SubMenu label={dictionary['navigation'].dashboards} icon={<i className='ri-home-smile-line' />}>
<MenuItem href={'/${locale}/dashboards/analytics'}>{dictionary['navigation'].analytics}</MenuItem>
</SubMenu>to:
<SubMenu label='dashboards' icon={<i className='ri-home-smile-line' />}>
<MenuItem href='/dashboards/analytics'>analytics</MenuItem>
</SubMenu> -
Remove the unused variable and it's related import from the
VerticalMenu.tsxfile. -
You need to remove
dictionaryparameter frommenuDatafunction in<GenerateVerticalMenu menuData={menuData(dictionary)} />fromsrc/components/layout/vertical/VerticalMenu.tsxfile.
-
-
Go to the
src/components/layout/horizontal/HorizontalMenu.tsxfile and make the same changes above in theVerticalMenu.tsxfile. -
Also you need to remove the
dictionary: Awaited<ReturnType<typeof getDictionary>>from the parameter and replace thelabelas above mentioned and removeexcludeLangfrom thesrc/data/navigation/verticalMenuData.tsxandsrc/data/navigation/horizontalMenuData.tsxfiles. -
Go to the
src/components/layout/horizontal/Header.tsxfile and make the following changes.-
Remove the
dictionaryfrom thepropsparameter of theHeaderfunction. -
Remove the
dictionary={dictionary}from the<Navigation>component. -
Remove the unused imports.
-
-
Go to the
src/components/layout/horizontal/Navigation.tsxfile and make the following changes.- Remove the
dictionaryfrom thepropsparameter of theNavigationfunction anddictionary={dictionary}from the<HorizontalMenu>component.
- Remove the
-
Remove the
src/components/layout/shared/LanguageDropdown.tsxfile and it's related import from the whole project. -
Go to the
src/app/layout.tsxfile and make the following changes.-
Remove the
TranslationWrappercomponent and it's related import. -
Remove
langparam from the<html>tag. -
Remove the
paramsfrom theRootLayoutfunction. -
Replace the following:
- const direction = i18n.langDirection[lang]
+ const direction = 'ltr' -
Remove the unused variable and it's related import from the file
-
-
Please note that you have to replace
const direction = 'ltr'as mentioned above in all the files whereconst direction = i18n.langDirection[lang]is used. -
Go to the
src/app/(dashboard)/(private)/layout.tsxfile and make the above changes and also make the following changes:-
Add the
disableDirectionprop in the<Customizer>component.<Customizer dir={direction} disableDirection /> -
Remove the
dictionary={dictionary}from the<Navigation>and<Header>components and it's related variable and imports. -
Remove the
paramsfrom theLayoutfunction. -
Remove
localefrom theAuthGuardcomponent.
-
-
Go to the
src/app/(blank-layout-pages)/(guest-only)/layout.tsxfile and make the following changes:-
Remove the
paramsfrom theLayoutfunction. -
Remove the
langfrom theGuestOnlyRoutecomponent
-
HOC(Higher Order Component) changes
-
Go to the
src/hocs/AuthGuard.tsxfile and make the following changes.-
Remove the
localefrom theAuthGaurdfunction. -
Remove
langfrom theAuthRedirectcomponent.
-
-
Remove the
src/hocs/TranslationWrapper.tsxfile and it's related import from the whole project.
Other Components Changes:
-
Remove the
excludeLangrelated code from thesrc/components/layout/shared/search/index.tsx,src/data/searchData.ts,src/components/GenerateMenu.tsxandsrc/components/GenerateMenu.tsxfiles. -
Go to the
src/components/AuthRedirect.tsxfile and make the following changes.- Remove the
langfrom theAuthRedirectfunction.
- Remove the
-
Remove the
src/components/LangRedirect.tsxfile and it's related import from the whole project. -
Go to the
src/components/GenerateMenu.tsxand make the following changes.-
Remove the following statement:
- const href = rest.href?.startsWith('http') ? rest.href : rest.href && (excludeLang ? rest.href : getLocalizedUrl(rest.href, locale as Locale)) -
Replace the
href={href}withhref={menuItem.href}in the<VerticalMenuItem>and<HorizontalMenuItem>components. -
Remove the unused variable and it's related import from the
GenerateMenu.tsxfile.
-
Configs and Utils changes:
-
Remove the following files/folders and it's related import from the whole project:
src/config/i18n.tssrc/utils/i18n.tssrc/utils/getDictionary.tssrc/data/directories
next.config Modifications:
-
Go to the
next.configfile and replace the redirects with the following code:redirects: async () => {
return [
{
source: '/',
destination: '/dashboards/crm', // replace with your default route
permanent: true
}
]
}
If you get any type errors after doing the above steps, you need to refresh/reopen your editor or you can remove .next folder and then try to run your project.
That's it! You have successfully removed i18n from your project 🥳.