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

After building, the tolgee server related keys of the project are not effective. #3

Open
Noah-Bytes opened this issue Nov 15, 2024 · 6 comments

Comments

@Noah-Bytes
Copy link

export default async function IndexPage() {
  const t = await getTranslate();
  return (
    <div className="background-wrapper">
      <div className="example">
        <Navbar>
          <Link href="/translation-methods">
            // Add key of the tolgee server
            {t('homepage.stats.subtitle')}
          </Link>
        </Navbar>
        <header>
          <img src="/img/appLogo.svg" />
          <h1 className="header__title">{t('app-title')}</h1>
        </header>
        <Todos />
      </div>
    </div>
  );
}
// work
npm run dev

// not work
npm run build
npm run start
@stepan662
Copy link
Contributor

stepan662 commented Nov 15, 2024

Hey, could you elaborate? What kind of error do you see, or what is the expected behavior?

@Noah-Bytes
Copy link
Author

Hey, could you elaborate? What kind of error do you see, or what is the expected behavior?

npm run dev

image

npm run build && npm run start

image

@stepan662
Copy link
Contributor

In dev mode Tolgee is loading data from directly from tolgee platform, in production mode it's using static files included in the project itself (or can be configured otherwise). So that's probably what's missing. It's documented here:
https://docs.tolgee.io/js-sdk/providing-static-data

@Noah-Bytes
Copy link
Author

In dev mode Tolgee is loading data from directly from tolgee platform, in production mode it's using static files included in the project itself (or can be configured otherwise). So that's probably what's missing. It's documented here: https://docs.tolgee.io/js-sdk/providing-static-data

How to support loading data from directly from tolgee platform in production mode

@Noah-Bytes
Copy link
Author

In dev mode Tolgee is loading data from directly from tolgee platform, in production mode it's using static files included in the project itself (or can be configured otherwise). So that's probably what's missing. It's documented here: https://docs.tolgee.io/js-sdk/providing-static-data

How to support loading data from directly from tolgee platform in production mode

I GET

// .use(DevBackend())
export function TolgeeBase() {
  return Tolgee().use(FormatIcu()).use(DevTools()).use(DevBackend()).updateDefaults({
    apiKey,
    apiUrl,
    fallbackLanguage: 'en',
  });
}

@stepan662
Copy link
Contributor

If you want to have your translations always up-to-date with the platform, you can use content delivery https://docs.tolgee.io/platform/projects_and_organizations/content_delivery/

Fetching translations directly from platform on production is not a good solution because of performance and reliability.

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

2 participants