Skip to content

Commit d6160e6

Browse files
authored
Merge pull request #92 from cyphercodes/feature/multi-language-support
feat: Multi-Language README Support
2 parents e61e6df + d1a625a commit d6160e6

5 files changed

Lines changed: 24 additions & 14 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ReadmeGenAI eliminates this friction by leveraging advanced AI to automatically
3333
<img src="assets/mainpage.png" alt="Main Page" width="600"/>
3434
<br>
3535
<br>
36-
<img src="assets/fearture-page.png" alt="Feature Page" width="600"/>
36+
<img src="assets/feature-page.png" alt="Feature Page" width="600"/>
3737
</p>
3838

3939
## Technical Architecture

src/app/api/generate/route.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const dynamic = "force-dynamic";
99
* AI README Generation Endpoint
1010
* Optimized for data accuracy, clean prompt interpolation, and multi-language support.
1111
*
12-
* @param {Request} req - The incoming request object containing the repo URL and optional language.
12+
* @param {Request} req - The incoming Fastify request object containing the repo URL and optional language.
1313
* @returns {Promise<NextResponse>} A JSON response containing the generated Markdown or an error message.
1414
*/
1515
export async function POST(req: Request) {
@@ -18,13 +18,7 @@ export async function POST(req: Request) {
1818
try {
1919
const body = await req.json();
2020
rawUrl = body.url;
21-
const rawLanguage =
22-
typeof body.language === "string" ? body.language.trim() : "";
23-
const normalized =
24-
rawLanguage.charAt(0).toUpperCase() + rawLanguage.slice(1).toLowerCase();
25-
language = (SUPPORTED_LANGUAGES as readonly string[]).includes(normalized)
26-
? normalized
27-
: "English";
21+
language = body.language || "English";
2822
} catch {
2923
return NextResponse.json({ error: "Invalid JSON body" }, { status: 400 });
3024
}
@@ -157,9 +151,12 @@ export async function POST(req: Request) {
157151

158152
const result = await model.generateContent(prompt);
159153
const response = await result.response;
160-
const markdown = response.text();
154+
const markdown = response.text().trim();
155+
const cleanMarkdown = markdown
156+
.replace(/^```(markdown|md)?\n/, "")
157+
.replace(/\n```$/, "");
161158

162-
return NextResponse.json({ markdown });
159+
return NextResponse.json({ markdown: cleanMarkdown });
163160
} catch (error: unknown) {
164161
const message =
165162
error instanceof Error ? error.message : "Internal Server Error";

src/components/Generator/SearchInput.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ export const SearchInput = ({
2929
const [language, setLanguage] = useState("English");
3030
const [error, setError] = useState<string | null>(null);
3131

32+
const languages = [
33+
"English",
34+
"Spanish",
35+
"French",
36+
"German",
37+
"Chinese",
38+
"Japanese",
39+
"Korean",
40+
"Portuguese",
41+
"Russian",
42+
"Arabic",
43+
"Turkish",
44+
];
45+
3246
const handleSubmit = (e: React.FormEvent) => {
3347
e.preventDefault();
3448
setError(null);
@@ -72,10 +86,9 @@ export const SearchInput = ({
7286
<select
7387
value={language}
7488
onChange={(e) => setLanguage(e.target.value)}
75-
aria-label="Select language for README generation"
7689
className="bg-zinc-900/50 border border-white/10 rounded-2xl px-6 py-6 text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all backdrop-blur-xl appearance-none cursor-pointer min-w-[140px]"
7790
>
78-
{SUPPORTED_LANGUAGES.map((lang) => (
91+
{languages.map((lang) => (
7992
<option
8093
key={lang}
8194
value={lang}

src/lib/gemini.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function getGeminiModel(): GenerativeModel {
1919
const genAI = new GoogleGenerativeAI(apiKey);
2020

2121
_model = genAI.getGenerativeModel({
22-
model: "gemini-2.5-flash",
22+
model: "gemini-1.5-flash",
2323
safetySettings: [
2424
{
2525
category: HarmCategory.HARM_CATEGORY_HARASSMENT,

0 commit comments

Comments
 (0)