How to configure and display multilingual website content in AnQi CMS?

Calendar 👁️ 66

AnQiCMS (AnQiCMS) is dedicated to helping users easily meet the needs of global content promotion, with built-in multilingual support features that allow you to flexibly configure and display content in different language versions of the website.No matter if you want to provide translations for static text in templates or create independent language versions for articles, products, and other core content, Anqi CMS offers intuitive and powerful tools.

Next, we will explore how to implement multilingual website content configuration and display in Anqi CMS.

Part one: Understanding the multilingual capabilities of Anqi CMS.

To implement a multilingual website in AnQi CMS, it mainly involves two levels:

  1. Translation of template text:For fixed text, navigation names, button text, etc., on the website interface, translation is done through the language package mechanism to ensure that interface elements display the target language when the user switches languages.
  2. Content entity multilingual management:For articles, products, single-page applications, and other dynamic content, you need to create independent content entities for each language and display them on the front end by switching language links.

The "Multi-site Management" feature of AnQiCMS also provides another flexible architecture option for building multilingual websites, where you can set up a site independently for each language. Although it is more independent in management, this article will mainly focus on how to implement multilingualism under the same AnQiCMS instance through language packs and content management.

The second part: Translating multilingual text in the configuration template

In order for your website interface to switch languages according to the user's selection, you need to create language packages for the static text in the template. Anqicms provides a simple{% tr %}Labels to handle such translations.

1. Establish the language package file structure

First, you need to create a folder named under your template directory.localesThe folder. In this folder, create a subfolder for each target language, and the folder naming follows the language code specification (for example, Simplified Chinese useszh-cn, English usesen-us)。In each language subfolder, you create one or moreymllanguage files in thedefault.yml.

For example, your directory structure might look like this:

./template/您的模板名称/locales
├── en-us
│   └── default.yml
└── zh-cn
    └── default.yml

2. Write the language package content

Indefault.ymlIn the file, you will define key-value pairs, where the key is the identifier you use in the template, and the value is the translation text of the identifier.

For example,zh-cn/default.ymlThe content may be:

"yourLocation": "您的位置"
"homePage": "首页"
"contactUs": "联系我们"

Anden-us/default.ymlThe content corresponds to:

"yourLocation": "Your Location"
"homePage": "Home"
"contactUs": "Contact Us"

3. Use in the template{% tr %}Tag

After completing the language package settings, you can use it in the template file.{% tr %}The label calls these translation texts. When the user switches the website language, AnQi CMS will automatically load the corresponding languagedefault.ymlfile and display the correct translation.

For example, if you want to display "Your location" at the top of the website, you can write it like this:

<div>
    <span>{% tr "yourLocation" %}:</span>
    <a href="/">{% tr "homePage" %}</a>
</div>

This way, when users visit the Chinese version of the website, they will see

Moreover, in the AnQi CMS backend's 'Global Function Settings', you can set the 'Default Language Pack', which is mainly used to control the display language of the backend management interface, as well as the language of the built-in prompts on the website front end, but it will not affect you through{% tr %}Tag or manually created content.

Part three: Manage content entities in different language versions.

For the core content of the website, such as articles, products, and single pages, you need to create independent content entities for each language.This means, you need to create a Chinese version and an English version of an article about "Anqi CMS introduction".

  • Articles and products:Under "Content Management", you can enter "Document Management" or "Product Management" to publish your content.Every time you publish a new article or product, make sure the category you choose corresponds to the language of the content, and enter the title, summary, and detailed content in that language.For example, you can create two top-level categories, 'Chinese articles' and 'English articles', and then publish articles in the corresponding language to the respective categories.
  • Single page:In the "Page Resources" under "Page Management", you can create different language versions for single pages such as "About Us", "Contact Us", and so on.For example, create a page named "About Us (Chinese)" and a page named "About Us (English)"}

By using this content separation management approach, you can ensure that each language's content accurately conveys information and is convenient for independent SEO optimization for users of different languages.

Part four: Implement multi-language site switching feature

To allow users to easily switch between different language versions, you need to add a language switcher to the website front end. Anqi CMS provides{% languages %}Tag to get information about all configured multilingual sites.

1. Get the language list

Use{% languages %}Tag, you can iterate through all available language sites:

{%- 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 %}

In the code above:

  • websitesThe variable is an array that contains detailed information for each language site.
  • item.LinkIs the URL of the language site.
  • item.LanguageNameIs the display name of the language (such as “Chinese”, “English”).
  • item.LanguageEmojiProvided a language Emoji icon (such as 🇨🇳, 🇬🇧).
  • item.LanguageIconIf you upload a language icon, the URL of the icon will be displayed.

2. Optimize search engine recognition: AddhreflangTag

To help search engines (such as Google) better understand that your website has multiple language versions and display them to users of the corresponding languages, you should include in the HTML's<head>Add in the blockhreflangLabel. This is crucial for international SEO.

Use{% languages %}Label combinationhreflang, it can be implemented like this:

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

Hereitem.LanguageIt will output the corresponding language code (such aszh-cn,en-us),search engines will display corresponding pages in search results of different languages according to this information.

Summary

The multilingual function of AnQi CMS, through template text translation and content entity separation management, provides a solid foundation for building a globalized website. It is complemented by a flexible language switcher and key SEO optimization (such ashreflangLabel), you can not only improve the user experience but also effectively expand the international market. Easy configuration, efficient operation, allowing your content to reach users all over the world.


Frequently Asked Questions (FAQ)

1. Why am I setting the 'default language pack' to English in the background 'global function settings', but the front-end website content is still in Chinese?The “Default Language Pack” setting mainly affects the display language of the AnQi CMS backend management interface, as well as some built-in prompts of the front-end system (if the template is called).

Related articles

How to use AnQi CMS to realize personalized display of different content models (such as articles, products)?

AnQi CMS is an efficient and customizable content management system, one of its core advantages is the flexible content model.This provides website operators with great freedom, allowing us to design unique structures and display methods for various content types such as 'articles', 'products', etc., thus realizing the personalized presentation of website content.Next, we will delve into how to take advantage of the powerful functions of AnQi CMS to achieve personalized display of content models.Understanding the content model of Anqi CMS

2025-11-08

How to display the friend link list on the AnQiCMS front-end page?

Friendship links are a way for websites to recommend each other, not only can they increase the number of external links to the website, but also be beneficial for search engine optimization (SEO), but also provide visitors with more entry points to related resources, enhancing the user experience.AnQiCMS provides a very convenient function for us to manage and display friend links. Next, we will learn together how to set up friend links in AnQiCMS and display them on the website's frontend page.### One, manage the friendship link in AnQiCMS background In AnQiCMS, managing friendship links is very intuitive

2025-11-08

How to display the user submitted comment form and its custom fields in AnQiCMS template?

In website operation, collecting user feedback and inquiries is an important link to improve service quality and understand user needs.AnQiCMS (AnQiCMS) provides a flexible and powerful message management function, allowing you to easily display a message form in the front-end template and support custom fields to meet the information collection needs of different business scenarios.To implement dynamic display of user submitted comment forms and custom fields in AnQiCMS templates, we mainly use a core tag: `guestbook`

2025-11-08

How to display a list of user-submitted comments on a website and handle the review status?

In website operation, user comments are an important element for building a community, obtaining feedback, and enhancing content interaction.For friends who use AnQiCMS (AnQiCMS) to build and manage websites, efficiently displaying user comments and managing their review status is a key factor in ensuring the quality of website content and user experience.The AnQiCMS provides very flexible and practical functions for this.

2025-11-08

How to optimize the setting of website URL static rules to enhance content display effect and SEO ranking?

In website operation, URL (Uniform Resource Locator) is not only the path for users to access the page, but also an important clue for search engines to understand the content and structure of the website.A well-optimized URL structure plays a crucial role in improving content display and SEO ranking.AnqiCMS (AnQi CMS) takes full consideration of SEO-friendliness in its design, providing flexible and powerful static rule management functions, allowing us to easily create beautiful and SEO-friendly URLs according to the needs of the website.Why do websites need static URLs

2025-11-08

How to customize the Anqi CMS template to meet the unique layout requirements of the website content?

In the digital age, a unique and functional website layout is the core element to attract users and convey brand information.AnQiCMS (AnQiCMS) is an enterprise-level content management system based on the Go language, which provides great flexibility to users with its efficient and customizable features, allowing you to easily create websites that meet specific content layout requirements.To fully utilize the powerful capabilities of AnQi CMS, custom templates are the key to personalized design.This not only involves visual beauty, but also concerns how to efficiently organize and display your website content.

2025-11-08

How to ensure efficient loading and display of images, videos, and other media resources on the page in Anqi CMS?

When operating a website, we all hope to provide visitors with a smooth and pleasant browsing experience.Among them, the loading speed of images, videos, and other media resources is undoubtedly a key factor affecting the experience.If the media resources on the page load slowly, visitors may become impatient and even leave directly.Lucky for it, AnQi CMS took full consideration of this from the beginning, providing various functions and strategies to help us efficiently manage and display these valuable resources.

2025-11-08

How to enhance the visibility of website content in search engine results using the advanced SEO tools of Anqi CMS?

In today's information explosion internet world, making your website content stand out among the vast sea of search results is a goal that every operator desires to achieve.Search engine optimization (SEO) is no longer optional; it is the foundation of success.Lucky for AnQiCMS (AnQiCMS) to know this, and it has built a series of powerful advanced SEO tools to help us easily improve the visibility of website content.AnQi CMS is dedicated to providing efficient content management solutions for small and medium-sized enterprises and content operation teams, with SEO-friendliness taking a core position in its design philosophy

2025-11-08