How to implement multilingual content switching and display in AnQiCMS templates?

Calendar 👁️ 80

As an experienced website operations expert, I am willing to deeply analyze the powerful capabilities of AnQiCMS in multi-language content switching and display.Today, as globalization becomes increasingly prevalent, making website content accessible to users of different languages has become a key factor for enterprises to expand their markets and enhance their brand influence.AnQiCMS, as an efficient and customizable content management system, naturally also provides a mature and flexible solution in this aspect.


How to implement multilingual content switching and display in AnQiCMS templates?

When building a website for a global audience, multilingual support is indispensable.AnQiCMS understands this and provides a highly effective and flexible mechanism that allows you to easily switch and display multilingual content in templates, thereby providing users from different regions with a localized browsing experience.

AnQiCMS mainly implements multilingual throughSystem language package, template translation tagsas well asMulti-site / content management strategyCompleted by combining, with the support of front-end language switching logic and SEO-friendlyhreflangSet.

Understand the multilingual foundation of AnQiCMS: system language packages and template translation

First, AnQiCMS provides multilingual support at the system level.In the background "Global Function Settings", you can select the website "Default Language Pack", the system built-in Chinese and English and other language options.This setting mainly affects the language of the AnQiCMS backend interface and some built-in system prompts.

But you might be curious, this is just the system's own language, so how is the content of the website's front-end translated? Don't worry, AnQiCMS provides strongtemplate translation tags——{% tr "关键词" %}.

  1. Set language package fileTo use{% tr %}Label, you need to create a named file under the template directory you are currently usinglocalesfolder. In thislocalesInside the folder, create a subfolder for each target language, for exampleen-usRepresents American English,zh-cnRepresents Simplified Chinese. Create a folder within each language folderdefault.yml(or any other name) file, used to store the translation key-value pairs for the language.

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

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

    Andlocales/en-us/default.ymlIt will be:

    "yourLocation": "Your Location"
    "contactUs": "Contact Us"
    
  2. Use translation tags in the templateOnce the language package file is set up, you can use it happily in the template.{% tr %}Labels to display the corresponding language text. For example, in your template file (such asheader.htmlorfooter.html) in the file, you do not need to hardcode 'Contact us', but write it as:

    <div>{% tr "contactUs" %}</div>
    

    When a user visits the website, AnQiCMS will automatically search for the corresponding language package file based on the current language environmentcontactUsTranslation and display. In this way, the navigation, footer information, button text, and other static content of the website can easily achieve multi-language switching.

Part two: the management strategy of multi-language dynamic content

For articles, products, and other dynamically generated content, the multi-language implementation strategy needs more detailed planning, AnQiCMS provides several flexible ideas:

  1. Multi-site management (recommended)AnQiCMS is one of its highlights for its powerful multi-site management function.You can set up an independent 'site' for each language, even though these sites are all running on the same AnQiCMS instance.For example, you canwww.yourdomain.com/en/Set to English site,www.yourdomain.com/zh/Set to Chinese site, oren.yourdomain.comandzh.yourdomain.com.

    In this mode, each language site has its independent documents, categories, tags, and so on.You need to manually create and translate content for each language version and publish it under their respective sites.This may mean that the workload of content entry increases, but it brings clarity to content management, with each language version of the content being completely independent and able to support more complex localization needs, such as displaying different products or services for different language versions.

    When calling different site data in the template, many tags (such asarchiveList/categoryList/systemsuch assiteIdParameters, allowing you to accurately obtain data from specified language sites.

  2. Content model and custom fields (auxiliary)For certain scenarios, you can also use custom fields in the content model to store content in different languages. For example, you can add to the article modelTitle_en/Content_enThis method is suitable for smaller content volumes, or relatively simple content structures, and when you do not want to maintain multiple 'sites'.

    However, this method requires additional logical judgments when rendering templates (such as{% if current_language == "en" %}{{archive.Title_en}}{% else %}{{archive.Title}}{% endif %}), and it may not be as intuitive in the backend management as the multi-site mode, content editors need to ensure that all language fields are updated.

3. Front-end language switching and SEO optimization

To enable users to switch between different language versions and to achieve better ranking in search engines, the following two aspects are crucial:

  1. Language switcherAnQiCMS provides{% languages websites %}Labels can help you easily build a language switch menu on the front end.This tag will return all configured multilingual site information, including language names, language codes, and corresponding link addresses.

    You can use it in the template like this:

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

    In this way, users can click on the link to directly jump to the website version of the corresponding language.

  2. hreflangTags (SEO key)To tell search engines that your website has multiple language versions and that these versions are interconnected, you need to include in the HTML's<head>Area additionhreflangtag. AnQiCMS's{% languages %}Tags can also be used to generate these SEO-friendly meta information:

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

    This setting can effectively prevent search engines from treating different language versions of content as duplicate content, and help users see the most suitable pages for their language preferences and geographic locations in search results.

Summary

AnQiCMS through a comprehensive strategy, allows the website's multilingual functionality to be flexible implemented.From language package configuration on the backend, to translation tags in templates, and to multi-site management mechanisms and front-end language switchers, each link aims to provide you with a solution that meets localization needs while also balancing operational efficiency and SEO effects.Whether it is a startup hoping to expand into the overseas market or a content operator who needs to manage multiple language versions of content, AnQiCMS can provide solid technical support.


Frequently Asked Questions (FAQ)

  1. Q: Does AnQiCMS support automatic translation functionality, or is it necessary to manually translate all content?A: AnQiCMS itself does not provide automatic translation functionality.Multilingual content requires manual translation and entry. This design is to ensure translation quality and content accuracy, as machine translation often cannot reach the level of professional human translation, especially when involving professional terminology or marketing copy.Of course, you can combine external translation services or tools to assist in your translation process.

  2. **Q: How to set up independent domain names for websites in different languages (such asen.yourdomain.com) or subdirectory (such aswww.yourdomain.com/en/)

Related articles

How does the AnQiCMS template handle arithmetic operations on numbers?

Under the powerful system of AnQi CMS, content operation is far more than just piles of text and images.For modern websites, especially for e-commerce, data display, or scenarios requiring dynamic calculations, the ability to perform numerical operations directly in templates is particularly important.It makes our pages no longer static display boards, but intelligent interfaces that can respond in real-time to data.

2025-11-07

How to get the current page's TDK (Title, Description, Keywords) information in AnQiCMS template?

As an experienced website operation expert, I am well aware that TDK (Title, Description, Keywords) is crucial for the search engine optimization (SEO) of any website, as it is like the facade of the website and a guide for search engines.A meticulously optimized TDK that can make your website stand out in the vast sea of online information, attracting targeted users to click and bringing valuable traffic.

2025-11-07

How to get the current website's system configuration information in AnQiCMS template (such as website name, Logo)?

As an experienced website operations expert, I am happy to discuss with you how to efficiently and flexibly obtain the current system configuration information of the website in AnQiCMS templates.This is not only the foundation of template development, but also the key to ensuring the consistency and maintainability of website information.AnQiCMS is an enterprise-level content management system developed based on the Go language, its concise and efficient design philosophy is also reflected in the use of template tags, making the call of technical information in the template layer extremely intuitive.### Cleverly utilize the `system` tag

2025-11-07

How to implement string content replacement in AnQiCMS template?

As an experienced website operations expert, I know that flexibility and efficiency are the key to success in daily content management.How to quickly and accurately adjust the string content on the page in terms of content display, whether it is for SEO optimization, brand consistency, or to meet the ever-changing market needs, it is a core skill we must master.Today, let's delve deeply into how the AnQiCMS template cleverly implements the replacement function of string content, empowering your content operation.

2025-11-07

How to implement unified management and content sharing for AnQiCMS?

In today's rapidly changing digital world, many enterprises and content operation teams find that simply having a website is no longer enough to meet their diversified business needs.No matter whether it is multi-brand operation, product line segmentation, regional market expansion, or multi-language promotion, efficiently managing multiple websites and achieving content collaboration is a huge challenge.AnQiCMS (AnQiCMS), as an enterprise-level content management system developed based on the Go language, was born to solve this pain point, it provides a set of elegant and powerful solutions, making it possible to manage multiple sites uniformly and share content

2025-11-07

How to optimize SEO for AnQiCMS (pseudo static, 301 redirection, Sitemap, etc.)?

In today's digital age, the success of a website cannot be separated from the favor of search engines.And Search Engine Optimization (SEO) is the key to making a website stand out among a sea of information.As an enterprise-level content management system designed specifically for small and medium-sized enterprises and content operation teams, AnQiCMS (AnQiCMS) deeply understands this, integrating many powerful SEO optimization features into the system, aiming to help users build search engine-friendly websites.Today, we will delve into how AnQiCMS uses core features such as pseudo-static, 301 redirect, Sitemap, and a series of advanced tools

2025-11-07

How does the content scraping and batch import feature of AnQiCMS help reduce the cost of content construction?

## AnQiCMS content collection and batch import: an intelligent solution for content construction cost In today's increasingly intense digital marketing competition, high-quality, continuously updated content is the core driving force for attracting users to the website, improving search engine rankings, and achieving business growth.However, content construction often involves a significant investment of time and manpower.For small and medium-sized enterprises and self-media operators, how to carry out content construction efficiently and economically is a common challenge they face.

2025-11-07

How does AnQiCMS prevent malicious content scraping and protect original copyright?

In the era of the internet where content is exploding, website operators are all working hard to protect original content.Malicious data collection (also known as "site scraping") not only damages the original creator's labor成果, but may also affect the website's SEO performance, even diluting brand influence.As an experienced website operations expert, I am well aware of the importance of a powerful and intelligent content management system for copyright protection.Today, let's delve deeply into how AnQiCMS (AnQiCMS) builds a solid defense for your original content through its exquisite functional design. AnQiCMS

2025-11-07