Manual 'lang'
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1 +1,2 @@
|
|||||||
*.config.js linguist-detectable=false
|
*.config.js linguist-detectable=false
|
||||||
|
cypress/support/*.js linguist-detectable=false
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const TranslationArea: FC<Props> = ({ value, onChange, readOnly, ...props }) =>
|
|||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
lang="auto"
|
|
||||||
dir="auto"
|
dir="auto"
|
||||||
resize="none"
|
resize="none"
|
||||||
rows={useBreakpointValue([6, null, 12]) ?? undefined}
|
rows={useBreakpointValue([6, null, 12]) ?? undefined}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect, useReducer, FC, ChangeEvent } from "react";
|
import { useEffect, useReducer, FC, ChangeEvent } from "react";
|
||||||
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from "next";
|
import { GetStaticPaths, GetStaticProps, InferGetStaticPropsType } from "next";
|
||||||
import Router from "next/router";
|
import Router from "next/router";
|
||||||
import { Stack, VStack, HStack, IconButton } from "@chakra-ui/react";
|
import { Stack, VStack, HStack, IconButton } from "@chakra-ui/react";
|
||||||
@@ -6,7 +6,7 @@ import { FaExchangeAlt } from "react-icons/fa";
|
|||||||
import { CustomError, Layout, LangSelect, TranslationArea } from "../components";
|
import { CustomError, Layout, LangSelect, TranslationArea } from "../components";
|
||||||
import { useToastOnLoad } from "../hooks";
|
import { useToastOnLoad } from "../hooks";
|
||||||
import { googleScrape, extractSlug } from "../utils/translate";
|
import { googleScrape, extractSlug } from "../utils/translate";
|
||||||
import { retrieveFiltered } from "../utils/language";
|
import { retrieveFiltered, replaceBoth } from "../utils/language";
|
||||||
import langReducer, { Actions, initialState } from "../utils/reducer";
|
import langReducer, { Actions, initialState } from "../utils/reducer";
|
||||||
|
|
||||||
const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ home, translationRes, statusCode, errorMsg, initial }) => {
|
const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ home, translationRes, statusCode, errorMsg, initial }) => {
|
||||||
@@ -46,6 +46,7 @@ const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ home, transl
|
|||||||
}, [source, target, delayedQuery, initial, home]);
|
}, [source, target, delayedQuery, initial, home]);
|
||||||
|
|
||||||
const { sourceLangs, targetLangs } = retrieveFiltered(source, target);
|
const { sourceLangs, targetLangs } = retrieveFiltered(source, target);
|
||||||
|
const { source: transLang, target: queryLang } = replaceBoth("exception", { source: target, target: source });
|
||||||
|
|
||||||
useToastOnLoad({
|
useToastOnLoad({
|
||||||
title: "Unexpected error",
|
title: "Unexpected error",
|
||||||
@@ -90,6 +91,7 @@ const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ home, transl
|
|||||||
placeholder="Text"
|
placeholder="Text"
|
||||||
value={query}
|
value={query}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
lang={queryLang}
|
||||||
/>
|
/>
|
||||||
<TranslationArea
|
<TranslationArea
|
||||||
id="translation"
|
id="translation"
|
||||||
@@ -97,6 +99,7 @@ const Page: FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ home, transl
|
|||||||
placeholder="Translation"
|
placeholder="Translation"
|
||||||
value={translation ?? ""}
|
value={translation ?? ""}
|
||||||
readOnly={true}
|
readOnly={true}
|
||||||
|
lang={transLang}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</VStack>
|
</VStack>
|
||||||
|
|||||||
Reference in New Issue
Block a user