定制 i5z1a/super-language-switcher 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

i5z1a/super-language-switcher

Composer 安装命令:

composer require i5z1a/super-language-switcher

包简介

A package to handle super language switching in Laravel

README 文档

README

445

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

  1. 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
  2. Register Service Provider

    Add the Super Language Switcher service provider to your config/app.php file:

    // 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.

  3. Publish Configuration (Optional)

    Optionally, publish the configuration file if you need to customize any settings:

    php artisan vendor:publish --provider="I5z1a\SuperLanguageSwitcher\Providers\SuperLanguageSwitcherServiceProvider"
  4. 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

  1. 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>
  2. 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-translate we 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 i5z1a/super-language-switcher 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-07-06