How to implement multi-language content switching and display correctly on the front end of AnQiCMS website?

When building a website for global users, providing multilingual content is a crucial step.AnQiCMS 作为一个功能全面的内容管理系统,为实现这一目标提供了灵活且强大的支持。This article will discuss in detail how to implement multi-language content switching and correct display on the front end of the AnQiCMS website.

Build a global website: AnQiCMS Overview of Multilingual Capabilities

AnQiCMS's multilingual support is designed to help website operators easily meet the needs of global content promotion.The core idea is to effectively separate and manage the interface text of the website (such as navigation menus, button text) from the actual content (such as articles, product descriptions).Through flexible configuration and template tags, you can provide a customized browsing experience for users of different languages, thereby expanding the international market and enhancing brand influence.

Implementing multilingual content switching mainly involves three aspects: setting up language packages on the back-end, categorizing content on the front-end, and applying language switching functions and translation tags in templates.

First step: Backend configuration, activate multi-language capability

Firstly, we need to make some basic configurations in the AnQiCMS backend to ensure the system has the ability to handle multiple languages.

  1. Set the default language package:Enter the "Global Settings" area of AnQiCMS backend, and you will find the option for the "Default Language Pack".Here, it is usually built-in with multiple languages such as Chinese and English.Select the main language of your website as the default language package.This setting mainly affects the built-in prompts, background interface text, and other information.It is a global setting that ensures that AnQiCMS runs in the language you choose.

第二步:内容录入,为英语准备专属内容

  • Create content specific to a language:In the "Content Management" module, whether publishing articles, products, or creating single-page applications, you need to create corresponding content for each target language separately.For example, if your website supports Chinese and English, when you write an article about the company introduction, you need to create a Chinese version of "Company Introduction" and an independent English version "Company Profile" article.
  • 保持内容关联性(SEO 考量):Although the content entries are independent, at the SEO level, we need to clearly inform search engines that these contents are different language versions of the same topic. You can set clear identifiers or URL naming conventions for different language versions of the content when entering the content (for example, the URL of a Chinese article may be}]}/zh/about-us,English article is/en/about-us),This helps to generate the correct content in the template laterhreflangLabel.

Step 3: Template creation, implement language switching and content display on the front end

The core of multilingual function lies in the presentation of front-end templates.AnQiCMS provides a series of powerful template tags, allowing you to easily implement language switching, interface translation, and dynamic content display on the front end.

  1. Language switching link: UselanguagesLabels can be placed at any position on the website (usually in the header or footer) to generate links for switching between different language versions. This label will retrieve all configured multilingual site information.

    English

    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}"/> {# 显示语言图标,如国旗 #}
        {%- else %}