定制 rosiersrobin/vue-translation-enforcer 二次开发

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

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

rosiersrobin/vue-translation-enforcer

最新稳定版本:2.0.4

Composer 安装命令:

composer require rosiersrobin/vue-translation-enforcer

包简介

Small package that enforces the use of existing translation strings in vue

README 文档

README

Small package that enforces the use of existing translation strings in vue

Installation

You can install the package via composer:

composer require rosiersrobin/vue-translation-enforcer

Install Laravel Vue i18n package:

npm i laravel-vue-i18n

load the plugin in your vite.config.js:

import { defineConfig, loadEnv } from "vite";
import i18n from "laravel-vue-i18n/vite";

export default defineConfig({
    plugins: [
        ...
        i18n(),
    ],
});

Bonus:

If you want to have auto generation during development, add this script to the plugins list:

run([
    {
        name: "translations-js",
        run: ["php", "artisan", "vte:export"],
        pattern: ["lang/**/*.php"],
    },
])

Create a helper function to 'get' the translations that is based off the laravel-vue-i18n package;

import { trans } from "laravel-vue-i18n";
import { TranslationKey } from "../translations/lang-keys";

export const getTrans = (
    key: TranslationKey, // this is the magic
    replace: Record<string, string> = {},
): string => {
    if (key === null || key === trans(key, replace)) {
        return "";
    }
    return trans(key, replace);
};

Add the following to your .gitignore:

/resources/js/translations/

Usage

To regenerate the translations array, simply run

php artisan vte:export

Tip: Place this in your deploy script before you build the project. If you don't, it will fail the build.

Contributing

Package is open for pull requests!

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

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