How to achieve multi-language content switching and display in AnQi CMS?

Calendar 👁️ 73

Under the wave of global content marketing, website support for multiple languages has become an indispensable function.AnQiCMS (AnQiCMS) fully understands this need and provides a flexible multilingual solution to help us easily display content in different languages for users.This article will discuss in detail how to implement multi-language content switching and display in Anqi CMS.

Differentiate between system language and content language

Before delving deeper, we first need to clarify the concept of two 'languages' in AnQi CMS:

  1. System backend language package:This mainly affects the display language of the Anqi CMS backend management interface, as well as some system prompt information built into the website.For example, by selecting the "Default language package" (such as Chinese, English) in the "Global feature settings", the backend interface and some system messages will switch accordingly.This will not change the language of the articles, products, or categories, etc., of the user-generated content you create.
  2. Front-end content language:This is what we usually refer to as the core of a multilingual website, which refers to the language versions of the actual content displayed to visitors on your website, such as articles, product descriptions, and category names.The AnQi CMS mainly carries different language contents through 'multi-site' or 'independent content management'.

Understood these two points, we can then start planning and implementing a multilingual website.

Core implementation methods: multi-site strategy and template layer translation

The core strategy of AnQi CMS to implement multilingual content switching is to create an independent "site" (which can be understood as an independent content management unit) for each language, and complement it with static text translation and language switching functions at the template layer.

1. Deploy and configure multilingual sites

Assuming you need to support both Chinese and English languages, you can set up an independent "site" for each language through the "Multi-site Management" feature of Anq CMS. This means that:

  • An independent domain name or subdomain:For example,www.yourdomain.comFor Chinese content,en.yourdomain.comFor English content.
  • Independent backend management:Each language site has its own backend for managing the content of that language.
  • Independent database and content:The content of Chinese sites is stored in their own database, and the content of English sites is also stored in their own database, with no impact on each other.

Overview of operation steps:

  1. Prepare the environment:Ensure that your server is installed with AnQi CMS and the runtime environment supports multi-site (such as Go project deployment under Baota panel).
  2. Add reverse proxy (if needed):If you use different domain names or subdomains for each language site, it may be necessary to configure reverse proxy on the web server (Nginx/Apache) to direct different domains to the same listening port of the Safe CMS (for example, 8001), and use the multi-site feature to differentiate.
  3. Create a new site in the AnQi CMS backend:
    • Log in to your main site backend.
    • Go to "Multi-site Management", click "Add New Site".
    • Enter detailed information for the new site, including:
      • Site Name:For example "English site"
      • Website address:Enter the corresponding English domain name, such ashttps://en.yourdomain.com
      • Database name:It is recommended to use a unique name related to the language, such asen_anqicms_com
      • Admin account password:Set up an independent backend management account for the language site.
      • Select the template to use:Can use the same or different templates for different language sites.

Repeat this process to create independent secure CMS sites for each language that needs to be supported.

2. Content creation and management

After creating each language site, the next steps become intuitive:

  • Log in to the backend of the corresponding site:For example, to manage English content, you need to log in:en.yourdomain.com/system/.
  • Create content independently:Create and publish articles, products, single pages, and categories independently in each language site.This means that the translated version of a Chinese article needs to be published as a new article on an English site.Although the workload will increase, this separation of management ensures high flexibility and independence of content.

3. Implementation of the front-end language switch button

We can take advantage of the Anqi CMS template to provide language switching functionality on the website front-end, allowing users to conveniently switch between different language versions.{% languages %}.

This tag can retrieve the list of all configured multilingual sites and provides information such as the name, code, icon, and link of each language site.

Sample code (usually placed in the header or footer of a website):

{%- languages websites %}
{%- if websites %}
<div class="language-switcher">
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}" lang="{{item.Language}}">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}"/>
        {%- else %}
        {{item.LanguageEmoji}} {# 如果没有图标,可以使用表情符号 #}
        {% endif %}
        {{item.LanguageName}}
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

This code will traverse all configured language sites, generate a link for each language, and users can click to jump to the corresponding language website.

4. Translation of template static text

In addition to dynamic content, there are many fixed texts in web templates that do not change with the article, such as navigation menu items, footer copyright information, form labels, etc. For these static texts, AnQi CMS provides{% tr %}Translate labels andlocalesTo implement multilingual support in the catalog.

Operation steps:

  1. Createlocalesdirectory:Create a folder named under the root directory of the template you are currently using.locales.

  2. Create a language configuration file:InlocalesUnder the directory, create a subdirectory for each language, and create it in this subdirectorydefault.ymlfiles for each language. For example:

    • template/your_theme/locales/zh-cn/default.yml
    • template/your_theme/locales/en-us/default.yml
  3. Edit the language configuration file:Indefault.ymlIn the file, define the translation content in key-value pairs.

    zh-cn/default.ymlExample:“`yml “yourLocation”: “Your Location” “contactUs”: “Contact Us” “

Related articles

How to customize the display layout of the article detail page in AnQiCMS?

In website operation, the article detail page is like the 'face' of the content, it not only carries the core information, but is also a key touchpoint for users to understand deeply and resonate.A well-designed, logically laid out detail page that highlights the value of the content, can significantly enhance the user's reading experience, effectively convey information, and even promote further interaction or conversion.AnQi CMS understands its importance and therefore provides highly flexible and customizable features, allowing us to easily create exclusive article detail pages with unique styles.

2025-11-08

How to display AnQiCMS articles with the `archiveDetail` tag?

When building rich web pages in AnQiCMS, the `archiveDetail` tag is undoubtedly the core tool for displaying article detail pages.It can flexibly obtain and present all the detailed information of articles or products, helping website operators easily create detail pages that match the brand image and user experience.

2025-11-08

How to get and display the document list of the specified category and model in AnQiCMS using the `archiveList` tag?

In Anqi CMS, efficiently managing and displaying website content is the key to improving user experience and search engine rankings.In order to achieve this goal, we often need to organize and display document lists according to specific categories or content models.At this time, the `archiveList` tag has become a powerful tool in our hands.It can help us flexibly extract the required content from the database and present it in a variety of ways.

2025-11-08

How does the `pageDetail` tag display the title, content, and thumbnail of a single page in AnQiCMS?

AnQiCMS provides an efficient way to manage independent pages, such as "About Us", "Contact Information", and so on.These pages usually have independent titles, content, and images, which need to be presented accurately in the front-end template.The `pageDetail` tag is the core tool designed by AnQi CMS to achieve this purpose, allowing us to easily extract and display the detailed information of a single page from the background database.Understanding the `pageDetail` tag: The core of single page content display In AnQiCMS

2025-11-08

How to take advantage of the pseudo-static function of Anqi CMS to optimize URL display for SEO?

In website operations, a clear and friendly website address (URL) not only improves user experience, but is also an indispensable part of search engine optimization (SEO).The original dynamic URL often contains complex parameters and symbols, which is not very friendly to search engine spiders and user understanding.The pseudo-static feature is exactly to convert these complex dynamic URLs into concise, readable, and static page-like URLs, thus optimizing the website's performance at both the visual and technical levels.

2025-11-08

What website modes (adaptive, PC+Mobile) does AnQi CMS support to display content?

In the era of multi-screen interconnection, how website content adapts to different devices directly affects user experience and the efficiency of information dissemination.AnQi CMS fully considers this requirement, providing users with a variety of flexible website content display modes, ensuring that your website can be presented in **status** on various devices such as PCs, tablets, and mobile phones, bringing visitors a smooth and comfortable browsing experience.The AnQi CMS mainly supports three core modes in content display: adaptive mode, code adaptation mode, and PC+Mobile independent site mode.These three patterns have their own focus

2025-11-08

How to ensure that watermarks and anti-crawling interference codes are automatically added when images are displayed in the Anq CMS?

In today's era of digital content prosperity, the copyright protection and prevention of content being maliciously collected has become an important issue that every website operator cannot ignore.Handcrafted images and content, without protection, are easily copied by dishonest elements with a single click, not only damaging the creators' labor but also affecting the authority and brand value of the website.

2025-11-08

How to display different types of data (such as) through the AnQi CMS custom content model?

When building a website, we often encounter situations where the content is not just simple 'articles' or 'products'.The traditional website content management system is often limited to a few predefined content types, which seems inadequate when facing diverse information display needs.AnQiCMS (AnQiCMS) is well-versed in this field, providing you with a powerful tool for easily handling various data displays through its flexible custom content model function.

2025-11-08