Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/i18n #12

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5afbca4
feat(packages): add @nivo/i18n package
vmnog Apr 29, 2024
42855a3
refactor: moves app/app/ under app/[lang]/app/ directory
vmnog Apr 29, 2024
0204039
feat(settings): add language settings section
vmnog Apr 29, 2024
c682d6b
refactor: rename directory from [lang] to [locale]
vmnog Apr 29, 2024
1538970
feat(settings): using current locale in language settings
vmnog Apr 29, 2024
e37774e
feat(packages): integrate auth with i18n
vmnog Apr 30, 2024
a79cb72
feat(settings): user can update preferred language
vmnog Apr 30, 2024
6346430
feat(dictionary): add dictionary client side provider with jotai
vmnog Apr 30, 2024
0e952ca
feat(i18n): use dictionary for language page
vmnog Apr 30, 2024
9fa9661
refactor: remove old src/app folders
vmnog Apr 30, 2024
570d7be
refactor(language-form): remove unecessary setLocale
vmnog Apr 30, 2024
4bf3e42
chore(i18n): remove unecessary react deps
vmnog Apr 30, 2024
2d4ed18
feat(i18n): use dictionary in settings sidebar
vmnog May 1, 2024
276e1b9
feat(i18n): use dictionary in settings profile
vmnog May 1, 2024
6157604
feat(i18n): use dictionary in settings developers
vmnog May 3, 2024
2b145e6
feat(i18n): use dictionary in settings organization
vmnog May 3, 2024
d7c832f
feat(i18n): use dictionary in settings developers logs
vmnog May 6, 2024
c626d21
feat(i18n): use dictionary in header
vmnog May 6, 2024
54f59ce
feat(i18n): use dictionary in summary
vmnog May 6, 2024
616e01c
feat(i18n): use dictionary in upload & uploads
vmnog May 14, 2024
d7a6fce
feat(i18n): use dictionary in batches
vmnog May 14, 2024
2124ace
feat(i18n): use dictionary in videos
vmnog May 17, 2024
26719ad
feat(i18n): add spanish dictionary
vmnog May 17, 2024
74d406e
feat(i18n): use dictionary in components
vmnog May 17, 2024
3839fd3
feat: adds server side context to avoid dictionary prop drilling
vmnog May 24, 2024
f28e732
refactor: remove unecessary proxy from server-context
vmnog May 24, 2024
b14c61c
feat(language-form): disable button if language is not changed
vmnog May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: remove unecessary proxy from server-context
vmnog committed May 24, 2024
commit f28e7328db74e5e43023ba0c1e8fadfc44e33882
22 changes: 2 additions & 20 deletions apps/web/src/utils/server-context.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
import { cache } from 'react';
import { cache } from "react";

export const serverContext = <T>(defaultValue: T): [() => T, (v: T) => void] => {
const getRef = cache(() => ({ current: defaultValue }));

const getValue = (): T => {
if (typeof getRef().current === 'object' && getRef().current !== null && !Array.isArray(getRef().current)) {
const target = getRef().current as unknown as object;

// Return a proxied object for objects to handle missing properties
return new Proxy(target, {
get(target, property) {
if (property in target) {
return target[property as keyof typeof target];
} else {
return `{{${property.toString()}}}`; // Handle missing properties
}
},
}) as unknown as T;
} else {
// Return the value directly for non-object types
return getRef().current;
}
};
const getValue = (): T => getRef().current;

const setValue = (value: T) => {
getRef().current = value;