cyon / vue-translation-manager

Interactively translate strings in Vue single file components
26 stars 12 forks source link

Error parsing empty component #9

Open aschempp opened 5 years ago

aschempp commented 5 years ago

If a file does not have any translations, the CLI tool will terminate with an error:

(node:31777) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'toUpperCase' of undefined (node:31777) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

MaxGfeller commented 5 years ago

@aschempp How can this be recreated? The CLI tool should not even show components that don't have any strings in them to be translated.

MaxGfeller commented 5 years ago

I fixed a bug in 1.1.0 that lead to the same error message. Could you try again and check if it works now?

aschempp commented 5 years ago

Thanks for the update! Now I get a slightly different message:

(node:36976) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token } in JSON at position 5186 (node:36976) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The component is rather simple, here's what it looks like:

<template>
    <div id="app">
        <error v-if="$store.state.error"/>
        <router-view v-else/>
    </div>
</template>

<script>
    // import "../../template/lib/jquery/jquery.js";
    // import "../../template/lib/popper.js/popper.js";
    // import "../../template/lib/bootstrap/js/bootstrap.js";

    import Error from './layouts/Error';

    export default {
        components: { Error },

        created() {
            this.$store.dispatch('auth/refresh');
        },
    };
</script>

<style rel="stylesheet/scss" lang="scss">
    @import "../assets/template/lib/perfect-scrollbar/css/perfect-scrollbar.css";
    @import "../assets/template/lib/jquery.steps/jquery.steps.css";
    @import "../assets/template/lib/SpinKit/spinkit.css";
    @import "../assets/template/css/bracket";

    @import "../assets/styles/app";
</style>
aschempp commented 5 years ago

I tried removing everything except the div and export statement, and the error still comes up.

MaxGfeller commented 5 years ago

I'm failing to recreate this. Could the error actually be from your messages file(s)? Sorry the error handling is still very basic.

When does the error occur? Right after running translate or only after selecting a file?

aschempp commented 5 years ago

After selecting that file. Other files work just fine. All languages are stored in the same file. Here's what my config looks like:

const path = require('path');
const { JSONAdapter } = require('vue-translation-manager');

module.exports = {
    srcPath: path.join(__dirname, 'src/components/'),
    adapter: new JSONAdapter({ path: path.join(__dirname, 'src/i18n/messages.json')}),
    languages: ['en', 'de'],
};
MaxGfeller commented 5 years ago

I can not recreate this, still. Is the messages file valid JSON? Did you try to validate this?

Could you provide a small reproducable example so i could look into this?

qzminski commented 5 years ago

I can confirm the issue but I am not sure what's the source of the problem…

the94air commented 3 years ago

@qzminski @MaxGfeller Turns out it shows this error if any of your templates contains an & or / or anything that can't be uppercased :joy: