How to configure AnQiCMS to support the display and switching of multilingual content?

Today, with the increasing globalization, website support for multi-language content display and switching has become a key factor in expanding international markets and serving diverse user groups.AnQiCMS as an efficient system focusing on enterprise content management fully considers this requirement and provides a flexible and practical multi-language configuration solution.This article will discuss in detail how to configure and manage multi-language content in AnQiCMS, helping your website easily achieve a global layout.

Understanding the multilingual mechanism of AnQiCMS

Before delving into the configuration, it is first necessary to understand the basic logic of AnQiCMS handling multilingual content. AnQiCMS divides the multilingual feature into several levels to meet the needs of different scenarios:

  1. System language package:Mainly for the background management interface and some built-in front-end prompt information. This determines the operation language of the AnQiCMS system itself.
  2. Template static text translation:Used for fixed text strings in website templates that do not change with the article content, such as navigation menu items, copyright statements, page module titles, and so on.
  3. Multilingual content management:The core part, involving the translation and display of actual business content such as articles, products, and single-page websites.AnQiCMS mainly supports content management of different language versions through the "multi-site" mechanism.
  4. Language Switching and SEO Optimization:Provide mechanisms for users to switch between different language versions and support the generation of content that is有利于搜索引擎识别 favorable to search engine recognition.hreflangLabel.

Understand these distinctions helps us to plan the construction process of a multilingual website more clearly.

I. Configure the system language package of AnQiCMS (backend and built-in prompts)

AnQiCMS provides built-in language packages for localizing the system interface and some built-in front-end prompts. Configuring this option is relatively simple:

You can navigate to the "Global Settings" area under "Background Settings" on the AnQiCMS backend management interface.Here, you will find an option named “Default Language Pack”.System usually comes with built-in Chinese, English, and other languages for your selection.Once you have selected the desired language and saved, the text on the back-end interface and some fixed prompts directly output by the system will be switched to that language.

It should be noted that this setting only affects the text display at the system level.Your article, product, category, and other specific business content language will not change, they need to be independently maintained through subsequent content management strategies.

Chapter II: Translation of static text in templates

The website template often contains a large amount of fixed text, such as headers, footers, sidebar titles, form labels, etc.This static text also needs to be switched according to the user's selected language.{% tr %}Translate labels and independent language files to achieve this.

  1. Create a language file:Under your AnQiCMS template directory, you need to create a folder namedlocalesin it.localesInside the folder, create a subfolder for each target language, for example,en-usrepresents American English,zh-cnRepresenting Simplified Chinese. Create one in each language subfolder..ymlfiles (for example)default.yml),used to store the corresponding translation key-value pairs of the language.

    For example,zh-cn/default.ymlmay include:

    "yourLocation": "您的位置"
    "homePage": "首页"
    

    whileen-us/default.ymlIt may include:

    "yourLocation": "Your Location"
    "homePage": "Home"
    
  2. Use translation tags in the template:On website templates (such asheader.html,footer.htmlor any other.htmltemplate file), you can use{% tr %}tags to call these translated texts.

    For example, if you need to display "Home" in the navigation bar of the website, you can write it like this:

    <a href="/">{% tr "homePage" %}</a>
    

    When the user visits the website, the system will automatically load the corresponding.ymlfile and display the correct translated text.

三、Manage Multilingual Content (Core Strategy: Multi-sites)

The recommended and core strategy for AnQiCMS to handle multilingual content is to utilize its powerful "multi-site management" function.This means you will create an independent "site" for each language, each with its own content, settings, and independent data, all managed by the same AnQiCMS installation instance.

  1. Create a multilingual site:

    • Plan the site structure:Firstly, decide the URL structure of your multilingual website. Common patterns include:
      • Independent domain: yourbrand.com(English),yourbrand.de(German)
      • Subdomain: cn.yourbrand.com(English),en.yourbrand.com(English)
      • Subdirectory: yourbrand.com/cn/(English),yourbrand.com/en/(English)
    • 新增站点:Login to the initial installation site backend of AnQiCMS, under the 'Multi-site Management' feature, click 'Add New Site'.Repeat this step for each language.
      • Site Name:例如“中文站”、“英文站”。
      • Website address:对应您规划好的域名、子域名或子目录URL。
      • Database name:Suggest using a separate database for each language site to ensure data isolation and ease of management.
      • Administrator account password:Set up independent backend login credentials for each site.
    • Configure server reverse proxy:No matter which URL structure you choose, you need to configure the corresponding domain resolution and reverse proxy rules in your web server (such as Nginx, Apache) or Baota/1Panel, etc., for each language site, to correctly direct traffic to the corresponding port of the AnQiCMS instance (if you are using Docker deployment, then it corresponds to the port of the Docker container).
  2. Content creation and maintenance:

    • Independent management:Each language site is an independent AnQiCMS instance.This means that you need to log in to the backend of each language site separately, and create and manage corresponding language articles, products, categories, and single-page content for each.For example, you created an article about "AnQiCMS Feature Introduction" on the Chinese site, and you also need to manually translate and create a corresponding "AnQiCMS Features" article on the English site.
    • Maintain content consistency:Although the content is independent, it is recommended to maintain consistency in the content structure (such as category hierarchy, page model fields) across different language sites for the sake of convenience and to maintain a good user experience.For example, if the Chinese site has a "News Center
    • Content association tips (optional):AnQiCMS currently does not have a built-in content association feature to automatically link content of different language versions.You can prompt the association of content in different language versions by custom fields or manually adding links to the article content.

IV. Implement language switching and SEO optimization

Users need an easy way to switch between language versions. At the same time, to ensure that the search engine can correctly identify the multilingual content of your website,hreflanglabel configuration is crucial.

  1. Language Switcher (using{% languages %}Label):AnQiCMS provides{% languages %}tags to get the list of all configured multilingual sites, you can use it to build a language switcher.

    In your website template (usually the header or footer, etc., common parts), you can write it like this: “`twig {%- languages websites %} {%- if websites %}

    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}" title="{{item.LanguageName}}">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}" />
        {%- else %}
        {{item.LanguageEmoji}} <!-- 或直接显示{{item.LanguageName}} -->
        {% endif %}
        {{item