ZBook currently supports Simplified Chinese and English. To add support for new languages to the frontend of ZBook, follow these steps:
Create a new language file in the zbook_frontend/messages
directory, such as fr.json
, and add the corresponding translation content. For example:
json
Ensure that you provide translation content for each field that needs to be translated.
In the zbook_frontend/src/navigation.ts
file, add the new language to the locales
configuration. For example, to add French support:
typescript
In the zbook_frontend/global.d.ts
file, add type declarations for the new language. You might need to update interfaces or type definitions to include the new language. For example:
typescript
To implement language switching in the navbar
, update the corresponding component to support selecting languages from localeMap
. If you have a Navbar
component, update the zbook_frontend/src/components/navbars/NavLang.tsx
file with the localeMap
:
typescript
After completing the above steps, test the changes by navigating to the zbook_frontend
directory, running npm run lint
and npm run build
. If there are no errors, you can start the local server and check the results.
After updating the frontend, some modifications are also needed on the backend. First, add the new language in the zbook_backend/util/lang.go
file:
go
Next, update the ValidateLang
function in the zbook_backend/val/validator.go
file to include the new language:
go
After completing the above frontend and backend changes, ZBook will support the new language!
The dashboard can support geographic information in multiple languages, which is somewhat decoupled from the frontend. If the backend does not have corresponding language database information, it will return default language en
information, as shown in the image below:
If you want the visitor information in the image above to support your language version, additional modifications are needed.
go
go
sql
To be continued
development/database