i5z1a/super-language-switcher
Composer 安装命令:
composer require i5z1a/super-language-switcher
包简介
A package to handle super language switching in Laravel
README 文档
README
Super Language Switcher (SLS) Package for Laravel
Super Language Switcher (SLS) integrates multilingual support into Laravel effortlessly. It adapts website layouts for languages like Arabic and English, switching between RTL and LTR seamlessly.
Installation
-
Install via Composer
You can install the package via Composer. Run this command in your terminal from your project directory:
composer require i5z1a/super-language-switcher:dev-main
-
Register Service Provider
Add the Super Language Switcher service provider to your
config/app.phpfile:// config/app.php 'providers' => [ // Other service providers... I5z1a\SuperLanguageSwitcher\Providers\SuperLanguageSwitcherServiceProvider::class, ];
Note: This step is required for all Laravel versions except Laravel 11, as Laravel 11 no longer requires manual service provider registration.
-
Publish Configuration (Optional)
Optionally, publish the configuration file if you need to customize any settings:
php artisan vendor:publish --provider="I5z1a\SuperLanguageSwitcher\Providers\SuperLanguageSwitcherServiceProvider" -
Usage
Use the provided artisan command to install language files:
php artisan language-switcher:install
✅ Now the Super Language Switcher (SLS) package is ready for your project!
Frontend
-
Language selection list
Add this list to the header or any page.
<!-- Language Switch Menu --> <select id="languageSelect"> <option value="ar">العربية</option> <option value="en">English</option> </select>
Include JS code in the header of the page or any page (💡) Tip: Include JS code in a place where all pages can access it to include it, for example the site header.
<!-- Include JavaScript --> <script src="{{ asset('js/translations.js') }}"></script>
-
Translations
To add translations you can go to the path (public\lang) and view the language files in JSON format, and the (SLS) package adds Arabic and English by default.
You can also easily add different languages later. Through these language files you can add translations to your page content, for example:
{ "welcome_message": "اهلا بموقعنا", "about_us_link": "عنا", "contact_us_link": "تواصل", }And then the English file as well:
{ "welcome_message": "Welcome to our site!", "about_us_link": "About Us", "contact_us_link": "Contact Us", }Note that we used the same keys in all language files to display them easily in the front-end
As shown here in the example:
<!-- Example placeholders --> <div data-translate="welcome_message"></div> <a class="translate-link" data-translate="about_us_link" href="#"></a> <a class="translate-link" data-translate="contact_us_link" href="/login"></a>
With
data-translatewe can enter the translation key to display the text from JSON files.
✅ Now your Laravel project supports multiple languages easily and without any routing.
Made with ❤ by @i5z1a to make developers' lives easier | All rights reserved.
i5z1a/super-language-switcher 适用场景与选型建议
i5z1a/super-language-switcher 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 07 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 i5z1a/super-language-switcher 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 i5z1a/super-language-switcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-07-06