1
I’m having trouble translating my page using the Lang.js in the Laravel.
I need to get the chosen language in the user settings using the Axios, and translate using a filter Vue.
The function responsible for collecting the language chosen by the user is the getLanguage(), which is in the created hook. 
After collecting the data, I saved config.linguagem and then I change the language using the Lang.setLocale(). 
However, when I check via console the chosen language, on mounted hook, he chooses the standard language "en", as if I haven’t set the user language. 
What am I doing wrong?
    <template>
    <table class="display table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>{{ 'cptasks.gerentes.nome' | trans }}</th>
                <th>{{ 'cptasks.gerentes.email' | trans }}</th>
                <th>{{ 'cptasks.gerentes.categoria' | trans }}</th>
                <th>{{ 'cptasks.gerentes.opcoes' | trans }}</th>
            </tr>
        </thead>
        <tbody>
            <tr>
               <th colspan="5">...</th>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>ID</th>
                <th>{{ 'cptasks.gerentes.nome' | trans }}</th>
                <th>{{ 'cptasks.gerentes.email' | trans }}</th>
                <th>{{ 'cptasks.gerentes.categoria' | trans }}</th>
                <th>{{ 'cptasks.gerentes.opcoes' | trans }}</th>
            </tr>
        </tfoot>
    </table>
</template>
<script>
    import Lang from '../lang.js';
    export default {
        data(){
            return{
                usuarios: [],
                config: {
                  linguagem: null,
                }
            }
        },
        created(){
            this.getLanguage();
        },
        mounted () {
            console.log(Lang.getLocale());
        },
        methods: {
            getLanguage(){
                var vm = this;
                axios.get('/configuracao/language')
                .then((response) => {
                    vm.config.linguagem = response.data;
                    Lang.setLocale(response.data);
                }).catch(e => {
                    console.log('Error', e);
                });
            }
        },
        watch: {
            'config.linguagem': function(value) {
                Lang.setLocale(value);
            }
        },
        filters: {
            trans: function (value) {
                if (!value) return '';
                return Lang.get(value);
            }
        },
    }
</script>
						
Ask a question in English on forum BR.
– RXSD
I searched here and have no idea which library this is (Lang.js). Could you specify better? It’s a separate library or already comes as Laravel?
– fernandosavio
@fernandosavio Laravel ( https://github.com/rmariuzzo/Laravel-JS-Localization ) + Javascript ( https://github.com/rmariuzzo/lang.js )
– jvitor