Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disabling automatic translations for certain pages #152

Open
lucascaro opened this issue Nov 9, 2020 · 1 comment
Open

Allow disabling automatic translations for certain pages #152

lucascaro opened this issue Nov 9, 2020 · 1 comment

Comments

@lucascaro
Copy link

Hi, is it possible to disable automatic translations done by onCreatePage?

Currently, the plugin is doing a deletePage + createPage for each locale in onCreatePage, if we have pre-translated content (say a page from a headless cms) that needs to only exist on a given locale, right now we need to fake an intl object in page.context which would stop the plugin from duplicating the page.

createPage({
        path: `/${locale}${node.url}`,
        component: resolve('path/to/component.jsx'),
        context: {
          id: node.id,
          language: language,
          intl: {
            language: locale,
            languages: [],
            routed: true,
            originalPath: node.url.url,
            redirect: false,
            defaultLanguage,
          },
        },
      });

is there a cleaner way to do this?

if not, would a PR be accepted to add a flag that prevents the automatic translations? for example, by adding language to a page, the plugin could assume this page belongs to the passed-in language only and shouldn't attempt to translate?

createPage({
        path: `/${locale}${node.url}`,
        component: resolve('path/to/component.jsx'),
        context: {
          id: node.id,
          language: language,
        }
      });

any better ideas?

@lucascaro lucascaro changed the title Disable automatic translations while keeping Context Disable automatic translations for certain pages Nov 9, 2020
@lucascaro lucascaro changed the title Disable automatic translations for certain pages Allow disabling automatic translations for certain pages Nov 11, 2020
@lucascaro
Copy link
Author

Example of how this could work: #160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant