Translations in a sub package











up vote
0
down vote

favorite












Im trying to translate some stuff in my React application. This works fine with i18next and react-i18next. Im using the withNamespaces HOC to render the translations and scan them with PoEdit. So far so good.



There are however two issues that i am facing. I also have a library that holds all my UI components. More like all the styling which extends from semantic-ui itself. Over there also some translations are applicable and i wanted to use the same react-i18next there as well. While testing in storybook all looks good however when i run npm link and link the package to my main application i suddenly get this error:



caught TypeError: (0 , _reactI18next.withNamespaces) is not a function


The second question i do have is that how can i extend the translations? For example i am having this library which translates field A to be "How are you doing?". However when running a project for a customer i notice that the customer wants another translation for something that is part of the lib.
Is there a way then still to overwrite it? Since the fact the translations are bundled of course and loaded internally in the component.



Below is some code how it looks:



import i18n from 'i18next';
import { reactI18nextModule } from 'react-i18next';
import XHR from 'i18next-xhr-backend';
import LanguageDetector from 'i18next-browser-languagedetector';

i18n
.use(XHR)
.use(LanguageDetector)
.use(reactI18nextModule)
.init({
load: 'languageOnly',
backend: {
loadPath: '../dist/locales/{{lng}}/{{ns}}.json'
},
fallbackLng: {
'en-US': ['en']
},
ns: ['uielements'],
defaultNS: 'uielements',
fallbackNS: 'uielements',
debug: false,
keySeparator: '##',
interpolation: {
escapeValue: false // not needed for react!!
},
react: {
wait: true,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
nsMode: 'default'
}
});

export default i18n;


And the components itself:



export default withNamespaces()(Dialog);









share|improve this question


























    up vote
    0
    down vote

    favorite












    Im trying to translate some stuff in my React application. This works fine with i18next and react-i18next. Im using the withNamespaces HOC to render the translations and scan them with PoEdit. So far so good.



    There are however two issues that i am facing. I also have a library that holds all my UI components. More like all the styling which extends from semantic-ui itself. Over there also some translations are applicable and i wanted to use the same react-i18next there as well. While testing in storybook all looks good however when i run npm link and link the package to my main application i suddenly get this error:



    caught TypeError: (0 , _reactI18next.withNamespaces) is not a function


    The second question i do have is that how can i extend the translations? For example i am having this library which translates field A to be "How are you doing?". However when running a project for a customer i notice that the customer wants another translation for something that is part of the lib.
    Is there a way then still to overwrite it? Since the fact the translations are bundled of course and loaded internally in the component.



    Below is some code how it looks:



    import i18n from 'i18next';
    import { reactI18nextModule } from 'react-i18next';
    import XHR from 'i18next-xhr-backend';
    import LanguageDetector from 'i18next-browser-languagedetector';

    i18n
    .use(XHR)
    .use(LanguageDetector)
    .use(reactI18nextModule)
    .init({
    load: 'languageOnly',
    backend: {
    loadPath: '../dist/locales/{{lng}}/{{ns}}.json'
    },
    fallbackLng: {
    'en-US': ['en']
    },
    ns: ['uielements'],
    defaultNS: 'uielements',
    fallbackNS: 'uielements',
    debug: false,
    keySeparator: '##',
    interpolation: {
    escapeValue: false // not needed for react!!
    },
    react: {
    wait: true,
    bindI18n: 'languageChanged loaded',
    bindStore: 'added removed',
    nsMode: 'default'
    }
    });

    export default i18n;


    And the components itself:



    export default withNamespaces()(Dialog);









    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Im trying to translate some stuff in my React application. This works fine with i18next and react-i18next. Im using the withNamespaces HOC to render the translations and scan them with PoEdit. So far so good.



      There are however two issues that i am facing. I also have a library that holds all my UI components. More like all the styling which extends from semantic-ui itself. Over there also some translations are applicable and i wanted to use the same react-i18next there as well. While testing in storybook all looks good however when i run npm link and link the package to my main application i suddenly get this error:



      caught TypeError: (0 , _reactI18next.withNamespaces) is not a function


      The second question i do have is that how can i extend the translations? For example i am having this library which translates field A to be "How are you doing?". However when running a project for a customer i notice that the customer wants another translation for something that is part of the lib.
      Is there a way then still to overwrite it? Since the fact the translations are bundled of course and loaded internally in the component.



      Below is some code how it looks:



      import i18n from 'i18next';
      import { reactI18nextModule } from 'react-i18next';
      import XHR from 'i18next-xhr-backend';
      import LanguageDetector from 'i18next-browser-languagedetector';

      i18n
      .use(XHR)
      .use(LanguageDetector)
      .use(reactI18nextModule)
      .init({
      load: 'languageOnly',
      backend: {
      loadPath: '../dist/locales/{{lng}}/{{ns}}.json'
      },
      fallbackLng: {
      'en-US': ['en']
      },
      ns: ['uielements'],
      defaultNS: 'uielements',
      fallbackNS: 'uielements',
      debug: false,
      keySeparator: '##',
      interpolation: {
      escapeValue: false // not needed for react!!
      },
      react: {
      wait: true,
      bindI18n: 'languageChanged loaded',
      bindStore: 'added removed',
      nsMode: 'default'
      }
      });

      export default i18n;


      And the components itself:



      export default withNamespaces()(Dialog);









      share|improve this question













      Im trying to translate some stuff in my React application. This works fine with i18next and react-i18next. Im using the withNamespaces HOC to render the translations and scan them with PoEdit. So far so good.



      There are however two issues that i am facing. I also have a library that holds all my UI components. More like all the styling which extends from semantic-ui itself. Over there also some translations are applicable and i wanted to use the same react-i18next there as well. While testing in storybook all looks good however when i run npm link and link the package to my main application i suddenly get this error:



      caught TypeError: (0 , _reactI18next.withNamespaces) is not a function


      The second question i do have is that how can i extend the translations? For example i am having this library which translates field A to be "How are you doing?". However when running a project for a customer i notice that the customer wants another translation for something that is part of the lib.
      Is there a way then still to overwrite it? Since the fact the translations are bundled of course and loaded internally in the component.



      Below is some code how it looks:



      import i18n from 'i18next';
      import { reactI18nextModule } from 'react-i18next';
      import XHR from 'i18next-xhr-backend';
      import LanguageDetector from 'i18next-browser-languagedetector';

      i18n
      .use(XHR)
      .use(LanguageDetector)
      .use(reactI18nextModule)
      .init({
      load: 'languageOnly',
      backend: {
      loadPath: '../dist/locales/{{lng}}/{{ns}}.json'
      },
      fallbackLng: {
      'en-US': ['en']
      },
      ns: ['uielements'],
      defaultNS: 'uielements',
      fallbackNS: 'uielements',
      debug: false,
      keySeparator: '##',
      interpolation: {
      escapeValue: false // not needed for react!!
      },
      react: {
      wait: true,
      bindI18n: 'languageChanged loaded',
      bindStore: 'added removed',
      nsMode: 'default'
      }
      });

      export default i18n;


      And the components itself:



      export default withNamespaces()(Dialog);






      reactjs i18next react-i18next






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 10 at 8:01









      Dirkos

      170117




      170117
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          I had the same issue. It turned out that withNamespaces HOC component was introduced in react-i18next version 8.0.0. Ensure that you have the latest version:



          npm i i18next@latest react-i18next@latest


          I just checked i18next v12.0.0 and react-i18next v8.3.8. Everything works fine.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52735382%2ftranslations-in-a-sub-package%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            I had the same issue. It turned out that withNamespaces HOC component was introduced in react-i18next version 8.0.0. Ensure that you have the latest version:



            npm i i18next@latest react-i18next@latest


            I just checked i18next v12.0.0 and react-i18next v8.3.8. Everything works fine.






            share|improve this answer

























              up vote
              0
              down vote



              accepted










              I had the same issue. It turned out that withNamespaces HOC component was introduced in react-i18next version 8.0.0. Ensure that you have the latest version:



              npm i i18next@latest react-i18next@latest


              I just checked i18next v12.0.0 and react-i18next v8.3.8. Everything works fine.






              share|improve this answer























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                I had the same issue. It turned out that withNamespaces HOC component was introduced in react-i18next version 8.0.0. Ensure that you have the latest version:



                npm i i18next@latest react-i18next@latest


                I just checked i18next v12.0.0 and react-i18next v8.3.8. Everything works fine.






                share|improve this answer












                I had the same issue. It turned out that withNamespaces HOC component was introduced in react-i18next version 8.0.0. Ensure that you have the latest version:



                npm i i18next@latest react-i18next@latest


                I just checked i18next v12.0.0 and react-i18next v8.3.8. Everything works fine.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 at 17:03









                Alexander

                707816




                707816






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52735382%2ftranslations-in-a-sub-package%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    Refactoring coordinates for Minecraft Pi buildings written in Python