The AnQi CMS provides an efficient and flexible solution for multilingual content configuration, aimed at helping us easily meet the needs of global content promotion.It cleverly distinguishes between system-level language settings and the localization of website content and templates, allowing us to finely manage content in different languages and ensure that users of different languages can browse the website smoothly.
We will learn in detail how to configure multilingual content in AnQi CMS and ensure its normal operation.
Understand the multilingual mechanism of AnQi CMS.
In Anqi CMS, the implementation of multilingualism can be understood from two levels:
- Translation of system interface and built-in textThis mainly refers to the language of built-in texts such as the background management interface and system messages.
- Localization of website content and templates.This is the dynamic content displayed on our website's front end to users, including articles, products, pages, and fixed text in templates.
First, in the "global feature settings" on the backend, we can find an option for the "default language package".Here usually built-in Chinese, English and other languages for us to choose from.The purpose of this setting is to change the language of the background management interface and some built-in prompts generated automatically by the system.For example, if we select 'English', then the background menu, prompts, and so on will all be displayed in English.
However, it should be noted that the settings of this "default language package" will not directly affect the language of specific content such as articles, products, categories, etc. on our website's front-end.The translation of this dynamic content requires a more powerful mechanism to be implemented - namely, by creating multiple independent "sites" to host content in different languages.
Configure multi-language site
To achieve multilingual display of website content, Anqi CMS adopts the core function of "multi-site management".This means that, for each language version, we can configure it as an independent "site" in AnQi CMS.The benefits of doing this are that each language site can have its own independent domain (or subdomain, subdirectory), content, template, even database, and achieve high isolation and flexibility.
The steps to configure a multilingual site are as follows:
Domain planning and resolutionBefore starting, we need to plan the domains for different language sites. For example, the main site is
www.yourdomain.com, an English site can been.yourdomain.com, a Japanese site can beja.yourdomain.com. After planning, you need to resolve these domain names to your server.Create a new site: Log in to your AnQi CMS main station backend and find the 'Multi-site Management' feature in the left menu.Click the "Add new site" button to start creating an independent site for a new language version.
On the new site configuration interface that pops up, you need to fill in the following key information:
- Site name: Give this language site a name that is easy to identify, for example, "English site", "Japanese site".
- Site root directorySpecify an independent root directory path for this new site. This is to ensure that the data and configuration of different sites can be stored independently. It is recommended to use
/app/Start, and use the domain name after removing the periods and converting it to underscores as the directory name, such as/app/en_yourdomain_com. - website address: Enter the complete access address you have planned for this language site, for example
http://en.yourdomain.com. - Administrator account/passwordSet a separate admin account and password for this new site.
- Database name: To ensure data independence, it is recommended to create a new database for each language site. Similarly, the domain name can be used as the database name by removing the dots and converting it to underscores, such as
en_yourdomain_comIf your database permissions are sufficient, you can choose to 'reuse the default database account information', and Anqi CMS will automatically create a new database. - Select the template to useYou can specify different templates for each language site, or use a set of multilingual compatible templates.
Reverse proxy configurationIf your CMS is deployed using Docker or Baota panel tools and accesses the domain name through reverse proxy, then the newly created site also needs to be configured with reverse proxy. This usually involves adding a new one in the Nginx or Apache configuration file.
serverBlock, point the domain name of the new language site to the internal port of the Aqin CMS (for example, 8001), and configure the pseudo-static rules.In the Baota panel, you can easily add it in "Website" -> "Reverse Proxy".
After completing these steps, your new language site will be created and configured. It will have independent backend and frontend access paths.
Prepare multilingual content
Now, we already have an independent language site, and the next step is to fill in the content.
Localization of dynamic contentFor articles, products, single-page applications, and other core dynamic content, you need to log in to the backend of the corresponding language site to publish and manage.For example, to publish an English article, you need to log in to the English site's backend, then as usual in "Content Management" to "Add Document", but at this time all the content is written in English.This means that if you have an "About Us" page, you will need to create a Chinese version of "About Us" in the Chinese site backend, and then create an English version of "About Us" in the English site backend.Each site's 'document classification', 'content model', and so on can also be independently configured as needed.
Translation of static template text: For fixed text in website templates, such as navigation menu items like 'Home', 'Contact Us', or form buttons like 'Submit', 'Search', we can use the template translation function of Anqi CMS to achieve this.
- Under your template directory (for example
/template/default), create a subdirectory namedlocalesThe directory. - In
localesUnder the directory, create subdirectories for each language andymlTranslate the file. For example:./locales ├── en-us │ └── default.yml └── zh-cn └── default.yml - In
zh-cn/default.ymlIn, you can define Chinese translation:"home": "首页" "contactUs": "联系我们" - In
en-us/default.ymlIn, you can define English translation:"home": "Home" "contactUs": "Contact Us" - In the template file, use
{% tr "key" %}tags to call translation:
when the user accesses the corresponding language<a href="/">{% tr "home" %}</a> <a href="/contact.html">{% tr "contactUs" %}</a>
- Under your template directory (for example