samosadlaker/statamic-langtag
最新稳定版本:v1.0.2
Composer 安装命令:
composer require samosadlaker/statamic-langtag
包简介
Statamic LangTag addon
README 文档
README
Statamic Langtag is a Statamic CMS addon that simplifies multi-language content handling. It provides a custom tag for managing locale-specific content blocks and routes to switch between supported languages. This addon is especially useful for Statamic sites with multiple locales, helping you easily display content in different languages based on user selection or session.
Features
- Custom Statamic tag (
{{ lang_tag }}and alias{{ lt }}) for rendering language-specific content - Configuration for default and supported locales (e.g., 'sk', 'en')
- Web route for switching locales via URL (
/lang/{locale}) - Automatically sets and remembers the user's locale in the session
- Easy integration with Statamic templates
Installation
Install via Composer:
composer require samosadlaker/statamic-langtag
Configuration
Publish the config file to customize locales:
php artisan vendor:publish --tag=statamic-langtag
Edit config/statamic/langtag.php:
return [ 'default' => 'sk', 'supported' => ['sk', 'en'], ];
Usage
Switch Locale
Navigate to /lang/{locale} to switch to a supported locale. For example: /lang/en or /lang/sk.
Template Tag
Use in your Antlers templates:
{{ lang_tag default="Ahoj" en="Hello" }}
Using antlers variable
{{ lang_tag default="{title}" en="{en_title}" }}
This will display the string based on the current locale, using 'default' if no match.
Check locale
Conditions for checking current locale
{{ {lang_tag:is locale="en"} ? 'Yes' : 'No'}}
Alias
You can also use the alias:
{{ lt default="Ahoj" en="Welcome" }}
Fix locale
{{lang_tag:fix }}
License
MIT License. See LICENSE for details.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-03