🌐Translations for the latest features (#78)
* 🌐Translations for the latest features
Also:
- Rename “Home” to Shared drive
- Hide banner with suggestion of downloading desktop app
- Fix Upload button on main screen
- Add separate buttons for the manage access and share by link
This commit is contained in:
@@ -181,7 +181,7 @@ export class DocumentsService {
|
||||
({
|
||||
id,
|
||||
parent_id: null,
|
||||
name: getVirtualFoldersNames(id),
|
||||
name: await getVirtualFoldersNames(id, context),
|
||||
size: await calculateItemSize(
|
||||
{ id, is_directory: true, size: 0 },
|
||||
this.repository,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
writeToTemporaryFile,
|
||||
} from "../../utils/files";
|
||||
import mimes from "../../utils/mime";
|
||||
import globalResolver from "../global-resolver";
|
||||
import gr from "../global-resolver";
|
||||
import { stopWords } from "./const";
|
||||
import { DriveFile } from "./entities/drive-file";
|
||||
import { DriveFileMetadata, FileVersion } from "./entities/file-version";
|
||||
@@ -26,12 +26,19 @@ export const isVirtualFolder = (id: string) => {
|
||||
return id === ROOT || id === TRASH || id.startsWith("user_");
|
||||
};
|
||||
|
||||
export const getVirtualFoldersNames = (id: string) => {
|
||||
export const getVirtualFoldersNames = async (id: string, context: DriveExecutionContext) => {
|
||||
const user = await gr.services.users.get({ id: context.user?.id });
|
||||
const locale = user?.preferences?.locale || "en";
|
||||
|
||||
if (id.startsWith("user_")) {
|
||||
return "My Drive";
|
||||
return gr.services.i18n.translate("virtual-folder.my-drive", locale);
|
||||
}
|
||||
|
||||
return id === ROOT ? "Home" : id === TRASH ? "Trash" : "Unknown";
|
||||
return id === ROOT
|
||||
? gr.services.i18n.translate("virtual-folder.shared-drive", locale)
|
||||
: id === TRASH
|
||||
? gr.services.i18n.translate("virtual-folder.trash", locale)
|
||||
: "Unknown";
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -232,11 +239,10 @@ export const getPath = async (
|
||||
? [
|
||||
{
|
||||
id,
|
||||
name: getVirtualFoldersNames(id),
|
||||
name: await getVirtualFoldersNames(id, context),
|
||||
} as DriveFile,
|
||||
]
|
||||
: [];
|
||||
|
||||
const item = await repository.findOne({
|
||||
id,
|
||||
company_id: context.company.id,
|
||||
@@ -276,7 +282,7 @@ export const addDriveItemToArchive = async (
|
||||
|
||||
if (!item.is_directory) {
|
||||
const file_id = item.last_version_cache.file_metadata.external_id;
|
||||
const file = await globalResolver.services.files.download(file_id, context);
|
||||
const file = await gr.services.files.download(file_id, context);
|
||||
|
||||
if (!file) {
|
||||
throw Error("file not found");
|
||||
@@ -398,7 +404,7 @@ export const getFileMetadata = async (
|
||||
fileId: string,
|
||||
context: CompanyExecutionContext,
|
||||
): Promise<DriveFileMetadata> => {
|
||||
const file = await globalResolver.services.files.getFile(
|
||||
const file = await gr.services.files.getFile(
|
||||
{
|
||||
id: fileId,
|
||||
company_id: context.company.id,
|
||||
|
||||
@@ -35,6 +35,7 @@ import { UserServiceImpl } from "./user/services/users/service";
|
||||
import { WorkspaceServiceImpl } from "./workspaces/services/workspace";
|
||||
|
||||
import { PreviewEngine } from "./previews/services/files/engine";
|
||||
import { I18nService } from "./i18n";
|
||||
|
||||
type PlatformServices = {
|
||||
auth: AuthServiceAPI;
|
||||
@@ -73,6 +74,7 @@ type TdriveServices = {
|
||||
engine: DocumentsEngine;
|
||||
};
|
||||
tags: TagsService;
|
||||
i18n: I18nService;
|
||||
};
|
||||
|
||||
class GlobalResolver {
|
||||
@@ -136,6 +138,7 @@ class GlobalResolver {
|
||||
engine: await new DocumentsEngine().init(),
|
||||
},
|
||||
tags: await new TagsService().init(),
|
||||
i18n: await new I18nService().init(),
|
||||
};
|
||||
|
||||
Object.keys(this.services).forEach((key: keyof TdriveServices) => {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import i18n from "i18n";
|
||||
import path from "path";
|
||||
import { logger } from "../../core/platform/framework/logger";
|
||||
import { Initializable, TdriveServiceProvider } from "../../core/platform/framework";
|
||||
|
||||
export class I18nService implements TdriveServiceProvider, Initializable {
|
||||
version = "0";
|
||||
|
||||
public translate(str: string, locale: string): string {
|
||||
return i18n.__({ phrase: str, locale: locale });
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async init(): Promise<this> {
|
||||
i18n.configure({
|
||||
locales: ["en", "ru", "fr"],
|
||||
defaultLocale: "en",
|
||||
directory: path.resolve("./locales/"),
|
||||
logWarnFn: msg => logger.warn(msg),
|
||||
logErrorFn: msg => logger.error(msg),
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./i18n-service";
|
||||
Reference in New Issue
Block a user