Skip to content

chore: Use jpn for Japanese #34

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
8 changes: 8 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ const withNextIntl = createNextIntlPlugin();
/** @type {import('next').NextConfig} */
const nextConfig = {
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],

redirects: async () => [
{
source: "/ja",
destination: "/jpn",
permanent: true,
},
],
};

export default withMDX(withNextIntl(nextConfig));
2 changes: 1 addition & 1 deletion src/api/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function translate(
const { source, target, dialect, pronoun, numReturnSequences = 1 } = params;

let prompt: string = "";
if (source === "ja" && target === "ain") {
if (source === "jpn" && target === "ain") {
prompt = `translate Japanese to Ainu (${dialect}, ${pronoun}): ${input}`;
} else {
prompt = `translate Ainu (${dialect}, ${pronoun}) to Japanese: ${input}`;
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export async function fetchTranslation(
transcriptions: {},
};

if (source === "ja") {
if (source === "jpn") {
result.transcriptions.translation = {
type: "kana",
text: to_kana(translation),
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default async function Home(props: HomeProps) {
setRequestLocale(params.locale);

const text = searchParams?.text;
const source = searchParams?.source ?? "ja";
const source = searchParams?.source ?? "jpn";
const target = searchParams?.target ?? "ain";
const dialect = searchParams?.dialect ?? "沙流";
const pronoun = searchParams?.pronoun ?? "first";
Expand Down Expand Up @@ -102,7 +102,7 @@ export default async function Home(props: HomeProps) {
action={`/${params.locale}`}
defaultValues={{
text: text ?? "",
source: searchParams?.source ?? "ja",
source: searchParams?.source ?? "jpn",
target: searchParams?.target ?? "ain",
dialect,
pronoun,
Expand Down
4 changes: 2 additions & 2 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { MetadataRoute } from "next";
export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: "https://tunci.aynu.io/ja",
url: "https://tunci.aynu.io/jpn",
lastModified: new Date(),
alternates: {
languages: {
Expand All @@ -12,7 +12,7 @@ export default function sitemap(): MetadataRoute.Sitemap {
},
},
{
url: "https://tunci.aynu.io/ja/about",
url: "https://tunci.aynu.io/jpn/about",
lastModified: new Date(),
alternates: {
languages: {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Composer/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const Composer: FC<ComposerProps> = (props) => {

const handleChangeSource = (source: string): void => {
setSource(source);
setTarget(source === "ja" ? "ain" : "ja");
setTarget(source === "jpn" ? "ain" : "jpn");

if (translation && textareaRef.current && !dirty) {
textareaRef.current.value = translation;
Expand All @@ -95,7 +95,7 @@ export const Composer: FC<ComposerProps> = (props) => {

const handleChangeTarget = (target: string): void => {
setTarget(target);
setSource(target === "ja" ? "ain" : "ja");
setSource(target === "jpn" ? "ain" : "jpn");

if (translation && textareaRef.current && !dirty) {
textareaRef.current.value = translation;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Composer/ComposerInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ export const ComposerInput: FC<ComposerInputProps> = (props) => {
const textareaLanguageRelatedAttributes: ComponentProps<
typeof TextareaAutosize
> = useMemo(() => {
if (source === "ja") {
if (source === "jpn") {
return {
lang: "ja",
lang: "jpn",
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Composer/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const LanguageSelector: FC<LanguageSelectorProps> = (props) => {
aria-labelledby={id}
onValueChange={onChange}
>
<SegmentedControl.Item value="ja">
<SegmentedControl.Item value="jpn">
{t("japanese")}
</SegmentedControl.Item>
<SegmentedControl.Item value="ain">{t("ainu")}</SegmentedControl.Item>
Expand Down
20 changes: 3 additions & 17 deletions src/components/ContentInfo/ContentInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,23 @@ export const ContentInfo: FC = async () => {
<ul>
<li>
<Link size="2" asChild>
<NextLink
rel="alternate"
href="/ain-Latn"
hrefLang="ain-Latn"
>
Aynu itak
</NextLink>
<NextLink href="/ain-Latn">Aynu itak</NextLink>
</Link>
</li>

<Separator orientation="vertical" aria-hidden />

<li>
<Link size="2" asChild>
<NextLink
rel="alternate"
href="/ain-Kana"
hrefLang="ain-Kana"
>
アイヌイタㇰ
</NextLink>
<NextLink href="/ain-Kana">アイヌイタㇰ</NextLink>
</Link>
</li>

<Separator orientation="vertical" aria-hidden />

<li>
<Link size="2" asChild>
<NextLink rel="alternate" href="/ja" hrefLang="ja">
日本語
</NextLink>
<NextLink href="/jpn">日本語</NextLink>
</Link>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Entry/Entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const EntryRoot: React.FC<EntryRootProps> = (props) => {
<blockquote lang="ain">{parse(textHTML)}</blockquote>
</Text>
<Text asChild>
<blockquote lang="ja">{parse(translationHTML)}</blockquote>
<blockquote lang="jpn">{parse(translationHTML)}</blockquote>
</Text>
</Flex>

Expand Down
2 changes: 1 addition & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getRequestConfig } from "next-intl/server";
import { routing } from "./i18n/routing";

// Can be imported from a shared config
export const locales = ["ain-Latn", "ain-Kana", "ja"];
export const locales = ["ain-Latn", "ain-Kana", "jpn"];

export default getRequestConfig(async ({ requestLocale }) => {
let locale = await requestLocale;
Expand Down
2 changes: 1 addition & 1 deletion src/i18n/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createNavigation } from "next-intl/navigation";
import { defineRouting } from "next-intl/routing";

export const routing = defineRouting({
locales: ["ain-Latn", "ain-Kana", "ja"] as string[],
locales: ["ain-Latn", "ain-Kana", "jpn"] as string[],
defaultLocale: "ain-Latn",
});

Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export default createMiddleware(routing);

export const config = {
// Match only internationalized pathnames
matcher: ["/", "/(ain-Latn|ain-Kana|ja)/:path*"],
matcher: ["/", "/(ain-Latn|ain-Kana|jpn)/:path*"],
};