1

在我的 laravel 5.6 / vue.js 2.5.7/ Bootstrap4.1.0 应用程序中,我使用 https://github.com/kazupon/vue-i18n 插件添加了 i18n 支持

它工作正常,但如果在 vue 代码中我使用语法,例如:

<p>{{ $t('message.hello', {name: 'visitor'}) }}</p>

我想在 Javascript 中获取标签,比如在 computed 中,因为某些标签取决于其他数据的值。

我可以这样做吗?如果可以,怎么做?

更新 :

我想详细说明我的任务:我有两种插入和更新模式的编辑器,在模板中我给其他子组件 editor-header 一个参数:

<template>
    ...
    <editor-header  :header_title="header_title"></editor-header>
    ...

        mounted() {
    ...
            this.setAppTitle(this.header_title, false);
        }, // mounted() {
    ...

    computed: {
            header_title: function () {
//                if (!this.is_insert) return "Edit " + t("document_category.document_category");
//                return "Add "+t("document_category.document_category");
                if (!this.is_insert) return "Edit document category";
                return "Add document category";
            },

在我的 i18n 文件中,我有两个标签:“编辑/添加”和“文档类别”,但我不知道是否有办法像我在 header_title 中尝试的那样进行操作。可以以其他方式完成吗?

谢谢!

4

0 回答 0