Skip to content

Commit

Permalink
Finish Portuguese Translation
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrozadotdev committed Oct 16, 2023
1 parent 1c4c65f commit 74529b1
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permissions:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_USER: ${{ github.actor }}
GH_TAG: ${{ github.ref_name }}
PBL_VERSION: ${{ github.ref_name }}
POCKETBASE_VERSION: ${{ vars.POCKETBASE_VERSION }}

Expand All @@ -20,6 +21,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Change Version
run: echo "${GH_TAG}" | cut -c 2- > ./client/VERSION
- name: Build Client
uses: actions/setup-node@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ TODO
/ossutil_output
package-lock.json

op.mjs
op.mjs
VERSION
1 change: 0 additions & 1 deletion client/VERSION

This file was deleted.

27 changes: 27 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
app = "app-name"
primary_region = "gru"

[build]
image = "ghcr.io/internoapp/pocketblocks:latest"

[mounts]
source = "data"
destination = "/pocketblocks/data"

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
[http_service.concurrency]
type = "requests"
hard_limit = 250
soft_limit = 200

[[http_service.checks]]
interval = "30s"
timeout = "5s"
grace_period = "10s"
method = "GET"
path = "/api/health"
7 changes: 4 additions & 3 deletions proxy/src/api/pocketbase/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Auth, FullUser } from "@/types";
import { APIResponse, PBAuth } from "./types";
import * as users from "./users";
import { createDefaultErrorResponse, pb } from "./utils";
import { t } from "@/i18n";

export async function login(
loginId: string,
Expand Down Expand Up @@ -47,11 +48,11 @@ export async function signup(loginId: string, password: string): APIResponse {
if (status === 400) {
let message = rawMessage;
if (response.data?.email?.code === "validation_invalid_email") {
message = "The email is invalid or already in use!";
message = t("authInvalidEmail");
} else if (
response.data?.username?.code === "validation_invalid_username"
) {
message = "The username is invalid or already in use!";
message = t("authInvalidUsername");
}
return {
status: 401,
Expand Down Expand Up @@ -120,7 +121,7 @@ export async function changePassword(
} catch (e) {
const { status } = e as ClientResponseError;
if (status === 400) {
return { status: 403, message: "Invalid password." };
return { status: 403, message: t("authInvalidPassword") };
}
return createDefaultErrorResponse(e);
}
Expand Down
7 changes: 4 additions & 3 deletions proxy/src/api/pocketbase/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PocketBase, { ClientResponseError, LocalAuthStore } from "pocketbase";
import { APIResponse } from "./types";
import { t } from "@/i18n";

const store = new LocalAuthStore("pb_admin_auth");

Expand All @@ -12,20 +13,20 @@ export function createDefaultErrorResponse(e: unknown): Awaited<APIResponse> {
if (status === 401) {
return {
status,
message: "You cannot access this resource.",
message: t("unauthorized"),
};
}
if (status === 404) {
return {
status,
message: "Resource not found",
message: t("notFound"),
};
}
if (import.meta.env.DEV) {
console.warn(`[POCKETBASE]: Error ${status}: ${message}`);
}
return {
status: 502,
message: "Something went wrong.",
message: t("serverError"),
};
}
24 changes: 23 additions & 1 deletion proxy/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
export default {
translation: {
init: "[I18N]: Init successfully!",
unknown: "Unknown",
authInvalid: "Invalid email/username or password.",
authInvalidEmail: "The email is invalid or already in use!",
authInvalidUsername: "The username is invalid or already in use!",
authInvalidPassword: "Invalid password!",
unauthorized: "You cannot access this resource!",
notFound: "Resource not found.",
serverError: "Something went wrong.",
changeMe: "Change Me",
emailChanged: "Email changed successfully!",
emailChangedSent:
"Email sent! Please visit your Mailbox and confirm your new email.",
emailVerified: "Email verified!",
emailVerifiedSent:
"Email sent! Please visit your Mailbox and verify your account.",
emailVerifiedSentWithLink:
"Access your email to verify your account. If you didn't receive an email, click here!",
passwordReset: "Password reset successfully!",
passwordResetSent:
"Email sent! Please visit your Mailbox and reset your password.",
allUsers: "All Users",
private: "Private",
anonymous: "anonymous",
},
};
24 changes: 23 additions & 1 deletion proxy/src/i18n/locales/pt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
export default {
translation: {
init: "[I18N]: Iniciado com sucesso!",
unknown: "Desconhecido",
authInvalid: "Email/username ou senha inválida.",
authInvalidEmail: "O email é inválido ou já está em uso!",
authInvalidUsername: "O usuário é inválido ou já está em uso!",
authInvalidPassword: "Senha incorreta!",
unauthorized: "Você não tem permissão para acessar esse recurso.",
notFound: "Recurso não encontrado",
serverError: "Algo deu errado.",
changeMe: "Me Mude",
emailChanged: "Email alterado com sucesso!",
emailChangedSent:
"Email enviado! Por favor, visite sua caixa de email e confirme-o.",
emailVerified: "Email verificado!",
emailVerifiedSent:
"Email enviado! Por favor, visite sua caixa de email e verifique-o.",
emailVerifiedSentWithLink:
"Acesse seu email para verificá-lo. Se você não recebeu um email, clique aqui!",
passwordReset: "Senha recuperada com sucesso!",
passwordResetSent:
"Email enviado! Por favor, visite sua caixa de email e recupere sua senha.",
allUsers: "Todos os Usuários",
private: "Privado",
anonymous: "Anônimo",
},
};
4 changes: 2 additions & 2 deletions proxy/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { AxiosInstance } from "axios";
import MockAdapter from "axios-mock-adapter";
import { sdk } from "@/api";
import mocks from "@/mocks";
import { initI18n, t } from "@/i18n";
import { initI18n } from "@/i18n";

sdk.setup();

initI18n().then(() => {
if (import.meta.env.DEV) {
console.warn(t("init"));
console.warn("[I18N]: Init successfully!");
}
});

Expand Down
21 changes: 10 additions & 11 deletions proxy/src/mocks/applications/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
createFolderList,
getAuthConfigs,
} from "@/utils";
import { t } from "@/i18n";

const createResponseData = async (
user: FullUser,
Expand All @@ -20,7 +21,7 @@ const createResponseData = async (
user: {
id: user.id,
createdBy: "anonymousId",
name: user.name !== "NONAME" ? user.name : "Change Me",
name: user.name !== "NONAME" ? user.name || t("changeMe") : t("changeMe"),
avatar: null,
tpAvatarLink: null,
state: "ACTIVATED",
Expand All @@ -30,7 +31,8 @@ const createResponseData = async (
{
authId: "EMAIL",
source: "EMAIL",
name: user.name !== "NONAME" ? user.name : "Change Me",
name:
user.name !== "NONAME" ? user.name || t("changeMe") : t("changeMe"),
avatar: null,
rawUserInfo: {
email: user.email,
Expand Down Expand Up @@ -80,9 +82,9 @@ async function showVerifiedMessage(user: FullUser, messageIns: any) {
const { status } = await auth.verifyEmailToken(verifyToken);
messageIns.destroy();
if (status === 200) {
messageIns.info("Email verified!");
messageIns.info(t("emailVerified"));
} else {
messageIns.error("Something went wrong!");
messageIns.error(t("serverError"));
}
} else if (
!isAdmin &&
Expand All @@ -91,19 +93,16 @@ async function showVerifiedMessage(user: FullUser, messageIns: any) {
) {
messageIns.destroy();
messageIns.info({
content:
"Access your email to verify your account. If you didn't receive an email, click here!",
duration: 5,
content: t("emailVerifiedSentWithLink"),
duration: 0,
style: { cursor: "pointer" },
onClick: () => {
auth.sendVerifyEmail().then((response) => {
messageIns.destroy();
if (response.status === 200) {
messageIns.info(
"Email sent! Please visit your Mailbox and verify your account.",
);
messageIns.info(t("emailVerifiedSent"));
} else {
messageIns.error("Something went wrong!");
messageIns.error(t("serverError"));
}
});
},
Expand Down
3 changes: 2 additions & 1 deletion proxy/src/mocks/applications/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
adminRoute,
} from "@/utils";
import { Application, Settings } from "@/types";
import { t } from "@/i18n";

type Permission = {
permissionId: string;
Expand All @@ -25,7 +26,7 @@ async function createPermissions(app: Application): Promise<Permission[]> {
type: "GROUP",
id: ALL_USERS_GROUP_ID,
avatar: "",
name: "All Users",
name: t("allUsers"),
role: "viewer",
});
}
Expand Down
11 changes: 5 additions & 6 deletions proxy/src/mocks/auth/bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@ import { auth } from "@/api";
import { mocker } from "@/mocker";
import { APIResponse } from "@/types";
import { createDefaultResponse, createDefaultErrorResponse } from "@/utils";
import { t } from "@/i18n";

export default [
mocker.post("/auth/email/bind", async ({ config, messageIns }) => {
const { email, token, password } = config.data;
let response: Awaited<APIResponse> = {
status: 502,
message: "Something went wrong.",
message: t("serverError"),
};
if (email) {
response = await auth.sendChangeEmail(email);
messageIns.destroy();
if (response.status === 200) {
messageIns.info(
"Email sent! Please visit your Mailbox and confirm your new email.",
);
messageIns.info(t("emailChangedSent"));
return createDefaultResponse();
}
}
if (token && password) {
response = await auth.verifyEmailChangeToken(token, password);
messageIns.destroy();
if (response.status === 200) {
messageIns.info("Email changed successfully!");
messageIns.info(t("emailChanged"));
window.history.pushState({}, document.title, window.location.pathname);
return createDefaultResponse();
}
}
messageIns.error("Something went wrong!");
messageIns.error(t("serverError"));
return createDefaultErrorResponse([response]);
}),
];
9 changes: 4 additions & 5 deletions proxy/src/mocks/auth/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import { auth } from "@/api";
import { mocker } from "@/mocker";
import { APIResponse } from "@/types";
import { createDefaultResponse, createDefaultErrorResponse } from "@/utils";
import { t } from "@/i18n";

export default [
mocker.post("/api/auth/form/login", async ({ config, messageIns }) => {
const { loginId, password, register, source, authId, resetToken } =
config.data;
let authResponse: Awaited<APIResponse> = {
status: 502,
message: "Something went wrong!",
message: t("serverError"),
};
if (authId === "RESET_PASSWORD") {
if (resetToken) {
Expand All @@ -28,7 +29,7 @@ export default [
status: 403,
body: {
code: 5608,
message: "Invalid email/username or password.",
message: t("authInvalid"),
success: false,
},
};
Expand All @@ -39,9 +40,7 @@ export default [
if (authId === "RESET_PASSWORD") {
messageIns.destroy();
messageIns.success(
resetToken
? "Password reset successfully!"
: "Email sent! Please visit your Mailbox and reset your password.",
resetToken ? t("passwordReset") : t("passwordResetSent"),
);
setTimeout(() => res(createDefaultResponse()), 2000);
} else {
Expand Down
3 changes: 2 additions & 1 deletion proxy/src/mocks/organizations/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createDefaultErrorResponse,
createDefaultResponse,
} from "@/utils";
import { t } from "@/i18n";

export default [
mocker.get(
Expand All @@ -21,7 +22,7 @@ export default [
joinTime: new Date(u.created).getTime(),
rawUserInfos: {
EMAIL: {
email: "PRIVATE",
email: t("private"),
},
},
})),
Expand Down
4 changes: 3 additions & 1 deletion proxy/src/mocks/users/currentUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { auth, groups } from "@/api";
import { mocker } from "@/mocker";
import { createDefaultResponse } from "@/utils";
import { t } from "@/i18n";

const defaultDataResponse = {
id: "",
Expand All @@ -21,7 +22,8 @@ export default [
...defaultDataResponse,
avatarUrl: user.avatar,
id: user.id,
name: user.name !== "NONAME" ? user.name : "Change Me",
name:
user.name !== "NONAME" ? user.name || t("changeMe") : t("changeMe"),
email: user.email,
groups: groupsResponse.data
? groupsResponse.data.map((g) =>
Expand Down
Loading

0 comments on commit 74529b1

Please sign in to comment.