How to implement the function of displaying and switching content in multiple languages?

Calendar 👁️ 76

Let your website go global: Multilingual content strategy and implementation of Anqi CMS

In today's globalized digital age, many businesses and content creators hope that their websites can reach a wider audience.This means providing multiple language content display and switching functions to meet the reading habits of users from different countries and regions.AnQiCMS (AnQiCMS) is an efficient content management system that fully considers this requirement, providing a flexible solution to help you easily implement multi-language functionality on your website.

In Anqi CMS, implementing multilingual display and switching of content is not just a simple option ticked in the background, but rather a strategic layout that combines the three core pillars of system-level language packages, template layer translation, and multi-site management.Understanding how these three work together is the key to building a multilingual website efficiently.

Firstly, we need to clarify a concept: Anqi CMS distinguishes between "system interface language" and "user content language" when handling multilingualism.The system interface language mainly refers to the back-end operation interface, certain built-in prompts, etc.The user content language refers to the articles, product descriptions, single pages, and so on that you actually publish on the website.Implement multilingual, detailed deployment is required at these two levels.

Plan multi-site: the cornerstone of multilingual content

Creating a separate site for each target language is the core strategy recommended by Anqi CMS. This means that if you want your website to support both Chinese and English, you will have a Chinese main site (such aswww.yourdomain.comAnd an English sub-site (for example)en.yourdomain.comorwww.yourdomain.com/en/). These sites, although they share the powerful core functions of the security CMS, are independent in content management.

The advantage of this mode is:

  • Content independent management:Each language content can be independently published, edited, and optimized to avoid confusion between different language contents.
  • SEO friendly:A standalone site structure or subdirectory is beneficial for search engines to distinguish between different language versions and tohreflangindex tags accurately.
  • Flexible configuration:Each language site can have an independent domain, static rules, template style, and even SEO settings to better adapt to the local market.

In the Anqi CMS backend, you can create and configure these independent language sites through the 'Multi-site Management' feature, including specifying different website addresses for each site, an independent database (if needed), and the template used.

Backend configuration: Set default language package (interface)

AnQi CMS provides built-in language package support, currently including Chinese and English, etc.You can find the 'Default Language Pack' option in the 'Global Function Settings' on the backend.Here you can select the corresponding language, which will affect the built-in prompts of the website and the display language of some system messages.

It should be noted that this setting mainly targets system-level text and will not automatically translate the articles, products, or categories you publish into the language of your choice.User-generated content multilingual management will be implemented through multi-site methods.

Template level: Translate static text

Web templates often contain some fixed text, such as the "Home", "About Us", "Contact Us" on the navigation bar, as well as copyright information in the footer, and sidebar titles, etc. These static texts are translated through AnQi CMS.{% tr %}Tags andlocalesDirectory structure to manage.

First, create a folder named under your template directory.localesThe folder. Inside this folder, create a subfolder for each language, named after the language code, for examplezh-cnand Simplified Chineseen-usAmerican English). Create one in each language folder.default.ymlfile.

For example,locales/zh-cn/default.ymlMay include:

"yourLocation": "您的位置"
"homePage": "首页"
"aboutUs": "关于我们"

Andlocales/en-us/default.ymlIt may correspond to:

"yourLocation": "Your Location"
"homePage": "Home"
"aboutUs": "About Us"

You can use these texts where you need to use them in the template.{% tr "键名" %}Tag to call. For example:

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

When the user visits a site in a different language, the system will automatically load the correspondingdefault.ymlfile and display the translated text.

Content level: publishing and managing multilingual content

As previously mentioned, the content published by users in Anqi CMS (articles, products, single pages, etc.) is bound to specific sites. This means that if you have a Chinese site and an English site:

  • Post and manage all Chinese articles, products, and pages on the Chinese site.
  • Post and manage all English articles, products, and pages on the English site.

In this mode, the content of different languages is completely independent. You can write different copy for each language market, and carry out independent SEO optimization.For example, Chinese articles may focus more on Baidu SEO, while English articles may focus more on Google SEO.

Front-end display and switching: language selector and SEO optimization

To make it easy for users to switch between different language versions and to optimize search engines' understanding of multilingual content, AnQi CMS provides{% languages %}Label. This label can help you build a language switcher and automatically generatehreflang.

Build a language switcher:You can use it in prominent positions on the website header or footer,{% languages %}Label to traverse all configured language sites and generate switch links:

{%- languages websites %}
{%- if websites %}
<div>
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}" />
        {%- else %}
        {{item.LanguageEmoji}}
        {% endif %}
        {{item.LanguageName}}
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

This code will generate a list of all language site links, and you can freely design its style according to your needs, such as displaying language names, flag icons, or Emoji expressions.

Hreflang tag SEO optimization:To inform search engines that your website has multiple language versions and they are interconnected, you need to add in the HTML's<head>Area additionhreflang.{% languages %}Tags can also automatically complete this task for you:

{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}

This way, search engines can accurately identify the different language versions of your website, and guide users to the most suitable language page for them, thereby improving the SEO performance in the international market.

By following these steps, Anqi CMS provides you with a comprehensive and flexible multilingual solution. Whether you are a small and medium-sized enterprise, a self-media operator, or a user who needs to manage multiple sites, you can efficiently achieve multilingual display and switching of content, helping your website go global.


Frequently Asked Questions (FAQ)

1. Why does AnQi CMS recommend creating a separate site for each language to manage content?Establishing independent sites (or subdomains/subdirectories) for each language is a universally accepted practice in the industry and one of the core design concepts of AnQi CMS.The benefits are multifaceted: it allows you to create content independently for different language versions, SEO optimization, and marketing strategies, avoiding content confusion, and improving website maintenance efficiency.For example, you can provide fully localized content and user experience for German-speaking users without worrying about content interference with English users.

2. How to translate static text such as "About Us", "Contact Information", etc. in templates, in addition to user-generated content like articles, products, etc.For fixed static text in the template, you can use{% tr %}the (translate) tag to combinelocalesmanage YAML files under the directory. Just inlocalesCreate a folder for the corresponding language in the directory anddefault.ymldefine key-value pairs in the file, then use the template to go through{% tr "键名" %}Reference it. So that when the user switches the language site, these static texts can also be translated and displayed accordingly.

3. In the "Global Function Settings", the "Default Language Package" and{% tr %}What are the differences between tags? How do they work together?The default language package mainly controls the interface language and built-in prompt information of the Anqi CMS system itself, such as the text in the background management interface.It sets the default system interaction language, which does not have a direct impact on the content of the articles you publish. And{% tr %}Tags are used to translate the static text that you manually write in the website front-end template (such as

Related articles

How to retrieve and display the SEO title and description of the current document in the template?

In website operation, Search Engine Optimization (SEO) is a key element to enhance website visibility.And the page title (Title) and description (Description) as the first information seen by search engines and users browsing, its importance is self-evident.AnQiCMS (AnQiCMS) knows this and therefore provides a flexible and powerful mechanism to retrieve and display these SEO elements in the template.### AnQi CMS's TDK (Title, Description,

2025-11-09

How to set and optimize the static URL structure of a website to enhance the display effect in search engines?

The importance of website operation and URL structure is self-evident.A clear and meaningful URL not only helps users better understand the page content, but is also a key factor in search engine optimization (SEO).Especially for content management systems, properly setting up the pseudo-static URL structure can significantly improve the display effect and user experience of the website in search engines.AnQiCMS as a content management system that focuses on SEO optimization, provides strong and flexible support in this aspect.It not only built-in a variety of commonly used pseudo-static rules

2025-11-09

What device adaptation modes does AnQiCMS support to optimize content display?

With the popularization of mobile internet, the types of devices used by users to access websites are becoming increasingly diverse, ranging from large-screen PC monitors to compact smartphones. The display effect of website content is directly related to user experience and the effective transmission of information.AnQiCMS is well-versed in this field, providing a variety of device adaptation modes to help users flexibly optimize content display and ensure that the website presents a**status**on any device.The device adaptation strategy of AnQi CMS is mainly divided into three types, each mode has its unique implementation method and applicable scenario

2025-11-09

How to filter and display a list of specific content based on recommendation attributes (such as "Headline

When operating a website, we often need to highlight certain important or recommended content, such as placing the latest news at the "top" or marking popular products as "recommended".AnQiCMS provides a flexible recommendation feature that allows you to easily filter and display these specific contents, thereby better guiding users to browse and enhance the value of the content. ### Understanding Recommendation Attributes and Their Functions The recommendation attributes in AnQiCMS can be considered as a special tag for content, used to mark its importance and display method on the website.These properties are rich in variety, for example: *

2025-11-09

How to display additional field data in the front-end template after customizing the content model?

AnQiCMS with its flexible content model function has brought great convenience to us in managing various types of website content.Whether it is an article, product, event, or any other content type that requires special fields, we can easily customize fields in the background to meet unique business needs.But when we eagerly create new fields in the background and fill them with data, new problems also arise: How can we accurately display these newly added custom field data on the front page of the website for visitors?Don't worry, AnQiCMS

2025-11-09

How to enable Markdown rendering and correctly display mathematical formulas and flowcharts in AnQiCMS?

In AnQiCMS, if you want to make your content more expressive, especially when it comes to displaying complex mathematical formulas or clear flowcharts, it is a very effective solution to flexibly use the Markdown editor.The new version of AnQiCMS has provided good support for this.Next, we will explore together how to enable these features in AnQiCMS, making your website content come alive.

2025-11-09

How to embed a comment list on the page and control its pagination display?

In website operation, user interaction is the key to enhancing site activity and content value.AnQiCMS provides a set of intuitive and powerful features that help us easily embed comment functions in pages and flexibly control the display of comment lists, especially its pagination management, which is crucial for pages with a large number of user comments. ### Enable comment functionality to bring content to life Firstly, we need to ensure that the comment functionality is enabled on the backend so that users can post comments.Once the comment feature is activated

2025-11-09

How to loop through and display all subcategories under a specified category in a template?

How to elegantly display all subcategories under a specified category in Anqi CMS template?For a content-rich website, a clear classification structure is the key to improving user experience and search engine friendliness.AnQiCMS (AnQiCMS) takes advantage of its flexible template engine and powerful tag system, allowing you to easily traverse and display all subcategories under a specified category on the website front end, whether it is a direct subcategory or a multi-level nested subcategory, you can handle it with ease.Today, let's discuss how to implement this feature in Anqi CMS templates.

2025-11-09