How to implement the switching display of multilingual website content?

Calendar 👁️ 82

In today's global digital environment, making a website support multiple language display is no longer an option, but a necessity for many businesses and content operators to expand into international markets and enhance user experience.AnQiCMS (AnQiCMS) took this into consideration from the beginning of its design, built-in powerful multilingual support features, helping us easily switch the display of website content between different languages.

How can we specifically operate to enable multilingual content switching capabilities for our Anqi CMS website?This can mainly be approached from three aspects: system language packages, front-end content display, and search engine optimization.


Configure the system language package and backend interface

Firstly, if you wish the management interface of the website backend or some system自带 prompts to display different languages, Anqi CMS provides a direct and convenient setting.

You just need to log in to the Anqi CMS backend, go to the "Global Function Settings" under the "Backend Settings" menu.Here, you will find an option named "Default Language Pack".Our AnQi CMS currently comes with Chinese and English language packages for your selection.After selecting the language you want, the system backend interface and some fixed prompts will switch to display accordingly.

However, a very important point needs our attention: the settings of this "default language package" mainly affect the built-in text of the system, such as the names of background menus, some system prompts, and so on.It will not automatically translate custom content published on your website, such as articles, product descriptions, single pages, etc.This content is created and published by ourselves and requires another method of processing.


Implement front-end multi-language content switching display

For truly user-oriented multilingual content on the website, such as your articles, product descriptions, single-page websites, etc., Anqi CMS provides a flexible mechanism to switch display.The core idea is to prepare a set of corresponding content for each language and guide users to access the corresponding language version through the front-end language switcher.

To achieve the switching of different language content, Anqi CMS provides a very practical template tag:{% languages websites %}. This tag can dynamically retrieve all the multilingual site information you have configured, including the names of each language, corresponding links, and cute language icons (Emoji or custom Icon).

Content management strategy:In AnQi CMS, to allow users of different languages to see the corresponding content, the most common and recommended practice is to set up an independent site or subdomain for each language. For example, your main site iswww.example.com(Chinese), you can seten.example.comorwww.example.com/en/(English) is the English site. This means you need to publish and manage content independently for each language version.When you create a new article or product, you need to create corresponding entries for each language version and ensure that the links are independent.

Implementation of the front-end language switcher:In the template files of the website, such as where you usually place the language switch button in the header or footer, you can use{% languages websites %}Labels to generate a language switch list.

A simple language switch code snippet would look like this:

{%- 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 iterate over all the configured language sites and generate a link for each language.Click these links, and the user will be directed to a different language version of the current page.For example, if the user is browsing the "About Us" page of a Chinese site, after clicking the English switch button, it will jump to the "About Us" page of the English site.

Translation of fixed text in theIn addition to the translation of the content itself, some fixed text in the website template, such as navigation menu items, page prompts, etc., can also be multilingualized through the translation tags of AnQi CMS. This requires you to create one in the template directorylocalesCreate a directory and create corresponding subdirectories for each language (such asen-us/zh-cn), then createdefault.ymlfiles to define the translation key-value pairs.

For example,zh-cn/default.ymlcan have:

"yourLocation": "您的位置"

Anden-us/default.ymlcorresponds to:

"yourLocation": "Your Location"

In the template, you can use{% tr "yourLocation" %}tags to display these translated static texts, the system will automatically select the correct translation based on the current site language setting.


Search Engine Optimization (SEO) Practices: Hreflang Tag

When building a multilingual website, a key point that cannot be ignored is Search Engine Optimization (SEO). In order for search engines to correctly identify your multilingual content and display different language versions to the appropriate audience, it is recommended to usehreflangtags are crucial.

hreflangThe tag can tell search engines that your website provides different language or regional versions of the same content.This helps to avoid duplicate content issues and ensures that users see the most relevant pages in their language and region.

SecureCMS also passes through{% languages websites %}Tags provide convenienthreflangOutput function. You just need to place the following code snippet in your website template's<head>Within the area, AnqiCMS will automatically generate the correct onehreflangTags:

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

This code will generate a `<link rel="alternate" hreflang="xx"` for each language version

Related articles

How to display and manage the display of images and video multimedia resources?

In website operation, high-quality multimedia content is the key to attracting visitors and improving user experience.AnQiCMS (AnQiCMS) is well-versed in this, providing comprehensive features to help users easily manage and flexibly display images and videos on their websites.From unified resource library to intelligent optimization settings, AnQiCMS makes multimedia management efficient and convenient. ### One, Core Multimedia Management Center: Image Resource Management Anqi CMS gathers all uploaded images and video resources into a centralized "Image Resource Management" module.This is not only the place where you store your materials

2025-11-08

How to display single page content on the front end of a website (such as About Us, Contact Us)?

In website operation, single-page content like "About Us" and "Contact Us" is indispensable, as it carries important functions such as displaying corporate image, providing contact information, or stating service terms.For friends using AnQiCMS, it is actually a very direct and flexible thing to beautifully display these single-page contents on the website front end. ### Single Page Content Management Overview Firstly, we need to create and manage these single pages in the AnQiCMS backend system.In the left navigation bar of the background, you can find the "Page Resources" menu

2025-11-07

How to display extra field data under a custom content model in Anqi CMS?

In AnQi CMS, the flexibility of the content model is one of the highlights of the project, allowing us to create and manage various content structures according to the actual business needs.Whether it is an article, product, event, or any other information that requires a specific field to describe, it can be easily realized through a custom content model.After adding exclusive additional fields to these models, the next step naturally is how to accurately and beautifully display this valuable data on the website front-end.This is not a complex task, Anqi CMS provides intuitive and convenient template tags to complete it

2025-11-07

How to specify and display different templates for specific documents or categories?

AnQi CMS provides a flexible and powerful template management mechanism that allows users to specify and display unique templates for documents, categories, and even single pages based on different content types or specific needs.This feature greatly enhances the personalized display capabilities and operational efficiency of the website content.Understanding the significance of template customization In website operations, the diversity of content often requires different presentation methods.An in-depth technical article may require a concise and clear layout so that readers can focus on the content itself;A promotional activity page may require prominent visual elements and call-to-action buttons

2025-11-07

How to format and display timestamps as readable dates or times in templates?

In the daily operation of AnQi CMS, we often need to handle various data, among which time information is undoubtedly the most common and important kind.Whether it is the publication date of the article, the update time, or the specific moment of user comments, these time data are usually stored in the form of timestamps.However, the original timestamp is not intuitive for ordinary users; they are more like a string of meaningless numbers.At this point, it becomes particularly important to convert these timestamps into a date or time format that is easy to understand.The Anqi CMS template system uses a syntax similar to the Django template engine

2025-11-08

How to implement pagination display of content lists in AnQi CMS?

In Anqi CMS, the pagination display of the content list is one of the key functions to enhance user experience, optimize website performance, and facilitate content management.AnQi CMS, with its flexible template tags and powerful content management capabilities, provides us with a simple and efficient way to meet this requirement.### The Importance of Pagination in Content Lists Imagine if your website had thousands of articles, products, or comments all displayed on one page. Not only would this make the page load incredibly slowly, but it would also cause users to get lost in the sea of information.

2025-11-08

How to display the website's friend link list on the front end?

In website operation, friendship links play an indispensable role.They not only help improve the quality of a website's external links, enhance search engine optimization (SEO) effects, but also bring additional traffic to the website and increase its credibility through peer recommendations.Our CMS understands the importance of friendship links, therefore, it provides an intuitive and convenient management function, and supports flexible front-end display methods, allowing website administrators to easily present these important cooperative resources on the page.### One, Friendship Link Management in AnQi CMS In the AnQi CMS backend management interface

2025-11-08

how to display the captcha in the message or comment function?

In website operation, the message and comment functions are important channels for interaction with users, but they often become hotbeds of spam and malicious flooding.It is particularly important to add captcha to these interactive functions to maintain a clean and high-quality communication environment.AnQi CMS understands this and provides a convenient solution for it.How can you display a captcha in the Anqi CMS message or comment feature to effectively resist spam?This mainly consists of two core steps: first, enable the captcha feature in the background, and then integrate the captcha element into the front-end template.### Step 1

2025-11-08