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

Add Fumadocs example #48

Merged
merged 5 commits into from
Jan 1, 2025
Merged

Add Fumadocs example #48

merged 5 commits into from
Jan 1, 2025

Conversation

fuma-nama
Copy link
Contributor

@fuma-nama fuma-nama commented Jan 1, 2025

It translates the Markdown + UI content.

Note that I found running languine translate on uncommitted files cause errors, I think they should be simply treated as new files, a fix is included to make it work

Copy link

vercel bot commented Jan 1, 2025

@fuma-nama is attempting to deploy a commit to the Pontus Abrahamsson's projects Team on Vercel.

A member of the Team first needs to authorize it.

@fuma-nama fuma-nama marked this pull request as ready for review January 1, 2025 10:21
@pontusab
Copy link
Contributor

pontusab commented Jan 1, 2025

This is amazing, thank you!

I would love if it was possible to do the processing with fastGlob in the translate global function to support multiple files for all translate functions something like this:

import { writeFile } from "node:fs/promises";
import { defaultTranslations } from "fumadocs-ui/i18n";
import { i18n } from "./lib/i18n";

// translate Fumadocs' UI content
await writeFile(
  "content/ui.json",
  JSON.stringify(defaultTranslations, null, 2),
);

export default defineConfig({
  llm: {
    provider: "openai",
    model: "gpt-4-turbo",
    temperature: 0,
  },
  version: "1.0.0",
  locale: {
    source: i18n.defaultLanguage,
    targets: i18n.languages.filter((v) => v !== i18n.defaultLanguage),
  },
  files: {
    json: {
      include: [
        {
          from: "content/ui.json",
          to: "content/ui.[locale].json",
        },
        {
          from: "content/app.json",
          to: "content/app.[locale].json",
        },
      ],
    },
    md: {
      include: ["content/docs/**/*.mdx"],
    },
  },
});

What do you think?

@pontusab
Copy link
Contributor

pontusab commented Jan 1, 2025

If so this could fix this issue too: #45 - let me know if you want me to do these change!

@fuma-nama
Copy link
Contributor Author

Hmm but this way we cannot define a more specific way to append the locale code to file names, because glob libraries don't actually support to. For example, if we define to to be content/docs/**/*.[locale].mdx, it conflicts with glob syntax, and we cannot implement it with existing libraries like fast-glob, a custom to function is still needed

@fuma-nama
Copy link
Contributor Author

fuma-nama commented Jan 1, 2025

This is the closest result I designed, otherwise it may not be able to maintain backward compatibility

export default defineConfig({
    md: {
      include: [
        {
          glob: "content/docs/**/*.mdx",
          to: (file, locale) => {
            const { dir, name, ext } = path.parse(file);

            return path.join(dir, `${name}.${locale}${ext}`);
          },
        },
      ],
      // ignore translated content
      filter: (file) => path.basename(file).split(".").length === 2,
    },
  },
});

@fuma-nama
Copy link
Contributor Author

Btw I can include them in the PR ;)

@pontusab
Copy link
Contributor

pontusab commented Jan 1, 2025

I like this much better! I guess this would solve #45 too?

@fuma-nama
Copy link
Contributor Author

done!

@pontusab pontusab merged commit 2259a30 into midday-ai:main Jan 1, 2025
1 check failed
@pontusab
Copy link
Contributor

pontusab commented Jan 1, 2025

LFG! Thanks!

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

Successfully merging this pull request may close these issues.

2 participants