fix(i18n): load translations from fs

This commit is contained in:
Amruth Pillai
2023-11-14 09:14:21 +01:00
parent d1f54010c7
commit 6303071410
10 changed files with 47 additions and 26 deletions

View File

@ -1,4 +1,4 @@
import { Controller, Get, Header, Param } from "@nestjs/common";
import { Controller, Get, Param } from "@nestjs/common";
import { UtilsService } from "../utils/utils.service";
import { TranslationService } from "./translation.service";
@ -20,8 +20,6 @@ export class TranslationController {
}
@Get("/:locale")
@Header("Content-Type", "application/octet-stream")
@Header("Content-Disposition", 'attachment; filename="messages.po"')
async translation(@Param("locale") locale: string) {
return this.utils.getCachedOrSet(
`translation:${locale}`,

View File

@ -31,6 +31,7 @@ export class TranslationService {
}
async fetchLanguages() {
const isDevelopment = this.configService.get("NODE_ENV") === "development";
const projectId = this.configService.get("CROWDIN_PROJECT_ID");
const accessToken = this.configService.get("CROWDIN_ACCESS_TOKEN");
@ -40,6 +41,20 @@ export class TranslationService {
);
const { data } = response.data as CrowdinResponse;
if (isDevelopment) {
data.push({
data: {
language: {
id: "zu-ZA",
locale: "zu-ZA",
editorCode: "zuza",
name: "Psuedo Locale",
},
translationProgress: 100,
},
});
}
return data.map(({ data }) => {
return {
id: data.language.id,