The AnQi CMS provides an efficient and flexible solution for multi-language content configuration, aiming to help us easily meet the needs of global content promotion.It cleverly separates the system-level language settings from the localization of website content and templates, allowing us to finely manage content in different languages and ensure smooth browsing for users of different languages.

Next, we will learn how to configure multi-language content in AnQi CMS and ensure its proper operation.

Understand the multi-language mechanism of AnQi CMS

In the AnQi CMS, the implementation of multilingualism can be understood from two levels:

  1. 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.
  2. Localization of website content and templates.This is the dynamic content of articles, products, pages, etc. displayed to users on our website, as well as the fixed text in templates.

Firstly, in the background's 'Global Feature Settings', we can find an option for the 'Default Language Pack'.Here is usually built-in with multiple languages such as Chinese and English 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 automatically generated by the system.For example, if we select "English", the backend menu, prompts, and other information will be displayed in English.

However, it should be noted that the setting of this "default language package" will not directly affect the language of specific content such as articles, products, and categories on our website's front end.The translation of this dynamic content requires a more powerful mechanism to be implemented — that is, by creating multiple independent "sites" to carry different language content.

Configure the multi-language “site”

To achieve multilingual display of website content, Anqi CMS adopts the core function of 'Multi-site Management'.This means that, with every language version, we can configure it as an independent 'site' in the Safe CMS.The benefits of this approach are that each language site can have its own independent domain (or subdomain, subdirectory), content, templates, even databases, which achieves a high degree of isolation and flexibility.

The steps to configure a multilingual site are as follows:

  1. Domain planning and resolutionBefore starting, we need to plan the domains for different language sites. For example, the main site iswww.yourdomain.com, and the English site can been.yourdomain.com,The Japanese site can beja.yourdomain.com. After planning, you need to resolve these domains to your server.

  2. Create a new siteLog in to your security CMS main station backend, find the 'Multi-site Management' feature in the left menu.Click the "Add new site" button to start creating a standalone site for a new language version.

    In the new site configuration interface that appears, you need to fill in the following key information:

    • Site Name: Give this language site a name that is easy to recognize, such as “English Site”, “Japanese Site”.
    • Site Root DirectorySpecify an independent root directory path for this new site. This is to ensure that the data and configurations of different sites can be stored independently. It is recommended to use/app/Start with, and use the domain name without dots and converted to underscores as the directory name, such as/app/en_yourdomain_com.
    • Website address: Fill in the complete access address you have planned for this language site, for examplehttp://en.yourdomain.com.
    • Administrator account/passwordSet an independent administrator account and password for this new site.
    • Database nameTo 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 periods and converting them to underscores.en_yourdomain_comIf your database permissions are sufficient, you can choose to 'Reuse default database account information', and SafeCMS will automatically create a new database.
    • Select the template to useYou can specify a different template for each language site, or use a set of multilingual compatible templates.
  3. Reverse proxy configurationIf your CMS is deployed using Docker or Baota panel and accessed through reverse proxy, the newly created site also needs to be configured with a reverse proxy. This usually involves adding a new configuration in the Nginx or Apache configuration file.serverSet the domain of the new language site to point to the internal port of AnQi CMS (e.g., 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 its own admin and frontend access paths.

Prepare multilingual content

Now, we have an independent language site, and the next step is to fill in the content.

  1. Localization of dynamic content For articles, products, single-page applications, and other core dynamic content, you need to log in to the corresponding language site backend to publish and manage.For example, to publish an English article, you need to log in to the English site's backend, and then add documents in the "Content Management" as usual. At this point, all content should be written in English.This means that if you have an "About Us" page, you will need to create the Chinese version in the Chinese site backend, and then create the English version in the English site backend.Each site's "Document Classification

  2. Translation of static template textFor fixed text in website templates, such as the 'Home' and 'Contact Us' in the navigation menu, or the 'Submit' and 'Search' button text in forms, we can use the template translation function of Anqi CMS to achieve this.

    • Under your template directory (for example/template/default), create a directory namedlocales.
    • Inlocales directory, create subdirectories for each language andymlTranslate the file. For example:
      
      ./locales
      ├── en-us
      │   └── default.yml
      └── zh-cn
          └── default.yml
      
    • Inzh-cn/default.ymlIn Chinese, you can define the Chinese translation:
      
      "home": "首页"
      "contactUs": "联系我们"
      
    • Inen-us/default.ymlIn English, you can define the English translation:
      
      "home": "Home"
      "contactUs": "Contact Us"
      
    • In the template file, use{% tr "key" %}tag to call the translation:
      
      <a href="/">{% tr "home" %}</a>
      <a href="/contact.html">{% tr "contactUs" %}</a>
      
      When the user accesses the corresponding language