samosadlaker/statamic-langtag 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

samosadlaker/statamic-langtag

最新稳定版本:v1.0.2

Composer 安装命令:

composer require samosadlaker/statamic-langtag

包简介

Statamic LangTag addon

README 文档

README

last tag

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-03