As an experienced website operation expert, I am more than happy to delve into the powerful capabilities of AnQiCMS in multi-language content switching and display.Today, with the increasing popularity of globalization, 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 provides a mature and flexible solution in this aspect.
How to implement the switching and display of multilingual content in AnQiCMS templates?
When building a website for a global audience, multilingual support is indispensable.AnQiCMS knows this point well and provides an effective and highly flexible mechanism, allowing you to easily switch and display multi-language content in templates, thus providing a localized browsing experience for users in different regions.
AnQiCMS mainly implements multi-language throughSystem language package, template translation tagsandMulti-site/content management strategyCompleted in combination with, while supplemented by the frontend language switching logic and SEO-friendlyhreflangsettings.
【en】Understand the multilingual foundation of AnQiCMS: System language package and template translation
But you may be curious, this is just the system's own language, how is the content on the website's front-end translated? Don't worry, AnQiCMS provides powerfultemplate translation tags——{% tr "关键词" %}.
Set the language package fileto use
{% tr %}Create a folder namedlocalesin the directory of the template you are currently using. In thislocalesInside the folder, create a subfolder for each target language, for example,en-usrepresents American English,zh-cnrepresents Simplified Chinese. In each language folder, create another,default.ymlFile named (or another name you define), used to store the translation of the corresponding language keys.For example, your
locales/zh-cn/default.ymlmay include:"yourLocation": "您的位置" "contactUs": "联系我们"while
locales/en-us/default.ymlwill be:"yourLocation": "Your Location" "contactUs": "Contact Us"Use translation tags in the templateOnce the language package file is set up, you can happily use it in the template.
{% tr %}Tags to display the corresponding language text. For example, in your template file (such asheader.htmlorfooter.htmlIn it, you do not need to hardcode 'Contact Us', instead write:<div>{% tr "contactUs" %}</div>When the user visits the website, AnQiCMS will automatically search from the corresponding language package file based on the current language environment
contactUsTranslation, and display it. In this way, the navigation, footer information, button text, and other static content of the website can be easily switched between multiple languages.
II. Management Strategy for Multilingual Dynamic Content
For dynamically generated content such as articles, products, etc., the multi-language implementation strategy requires more detailed planning, AnQiCMS provides several flexible ideas:
Multi-site management (recommended)AnQiCMS one of the highlights is its powerful multi-site management function.You can set a separate 'site' for each language, even if these sites are all running under the same AnQiCMS instance.
www.yourdomain.com/en/Configured as an English site,www.yourdomain.com/zh/Configured as a Chinese site, oren.yourdomain.comandzh.yourdomain.com.In this mode, each language site has its own documents, categories, tags, and other content.You need to manually create and translate content for each language version and publish it under the respective sites.Although this may mean an increase in the workload of content entry, it brings clarity to content management. Each language version of the content can be completely independent, and it can support more complex localization requirements, such as displaying different products or services in different language versions.
When calling different site data in the template, many tags (such as)
archiveList/categoryList/systemetc.) all supportsiteIdParameters, allowing you to precisely retrieve data from specified language sites.Content model and custom fields (assistant)'} ]For certain specific scenarios, you can also use custom fields in the content model to store content in different languages. For example, you can add in the article model.
Title_en/Content_enThis method is suitable for cases where the content volume is small, or the content structure is relatively simple, and you do not want to maintain multiple 'sites'.However, this method requires additional logical judgments during template rendering (for example,
{% if current_language == "en" %}{{archive.Title_en}}{% else %}{{archive.Title}}{% endif %})And it may not be as intuitive on the backend management as the multi-site mode, content editors need to ensure that all language fields are updated.
Three, Front-end Language Switching and SEO Optimization
In order for users to switch between language versions and achieve better rankings in search engines, the following two aspects are crucial:
Language SwitcherAnQiCMS provides
{% languages websites %}Tags, which can help you easily build a language switch menu on the front-end.This tag will return all configured multilingual site information, including language name, language code, and corresponding link address, etc.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 %}Users can click the link to directly jump to the corresponding language version of the website in this way.
hreflangTags (SEO key)To inform search engines that your website has multiple language versions and that these versions are interlinked, you need to add the in HTML.<head>area tag.hreflangAnQiCMS'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 avoid search engines treating different language versions of content as duplicate, and helps users see the pages most suitable for their language preferences and geographic locations in search results.
Summary
AnQiCMS implements a comprehensive set of strategies to flexibly realize the multilingual function of the website.From the language package configuration in the background, to the translation tags in the templates, to the multi-site management mechanism and the front-end language switcher, each link is designed to provide you with a solution that meets both localization needs and operational efficiency and SEO effects.Whether it is a startup looking to expand into the international market or a content operator who needs to manage multiple language versions of content, AnQiCMS can provide solid technical support.
Common Questions (FAQ)
Q: Does AnQiCMS support automatic translation, or is manual translation of all content required?A: AnQiCMS itself does not provide an automatic translation feature.Manual translation and entry of multilingual content is required.This design is to ensure the quality and accuracy of the translation, as machine translation often cannot reach the level of professional human translation, especially when it involves professional terminology or marketing copy.Of course, you can combine external translation services or tools to assist in your translation process.
**Q: How to set up separate domain names for websites in different languages (such as
en.yourdomain.com)or subdirectory(such aswww.yourdomain.com/en/)