承接 bambamboole/laravel-i18next 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bambamboole/laravel-i18next

最新稳定版本:0.3.0

Composer 安装命令:

composer require bambamboole/laravel-i18next

包简介

A laravel package which provides a HTTP backend for i18next.js

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

If you are using i18next in your frontend and Laravel in your backend, this package is for you.

How does it work?

The package provides the routes to fetch the translations and to save missing translations when using i18next-http-backend.
it supports Laravels JSON and PHP translation files and converts them on the fly to be compatible with i18next.

Installation

You can install the package via composer.

composer require bambamboole/laravel-i18next

Usage

The package is still in its early development and therefor pretty opinionated and not very flexible.

It provides two routes. One is for fetching the translations and the other one is for saving missing translations.

Fetching translations

The route

With Vue.js

To use the translations in your Vue.js components you can use the i18next-vue package.

npm install -D i18next-vue i18next-http-backend

To configure i18next-vue you can use the following code snippet:

import I18NextVue from 'i18next-vue';
import HttpBackend from 'i18next-http-backend'

i18next.use(HttpBackend).init({
    saveMissing: true,
    lng: 'en',
    backend: {
        // This is needed for CSRF protection
        withCredentials: true,
        customHeaders: () => {
            const csrf = document.querySelector<HTMLElement>('meta[name="csrf-token"]')

            return csrf === null ? {} : {'X-CSRF-TOKEN': csrf.getAttribute('content')}
        },
    },
});

//...

app.use(I18NextVue, {i18next})

Testing

composer test

Contributing

Ideas/Roadmap

  • Add more tests
  • Make the package more flexible
  • Support namespaces
  • Support i18next multiload

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email manuel@christlieb.eu instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-01