Skip to content

Ae/minify data #406

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

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft

Ae/minify data #406

wants to merge 44 commits into from

Conversation

ErnestM1234
Copy link
Contributor

No description provided.

@ErnestM1234 ErnestM1234 requested a review from a team as a code owner June 17, 2025 18:30
@ErnestM1234 ErnestM1234 marked this pull request as draft June 17, 2025 18:30
Copy link

vercel bot commented Jun 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
gt-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 20, 2025 5:42pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
example-ai-chatbot ⬜️ Ignored (Inspect) Jun 20, 2025 5:42pm
example-create-react-app ⬜️ Ignored (Inspect) Jun 20, 2025 5:42pm
example-gt-next-starter ⬜️ Ignored (Inspect) Jun 20, 2025 5:42pm
example-next-create-app ⬜️ Ignored (Inspect) Jun 20, 2025 5:42pm
example-vite-create-app ⬜️ Ignored (Inspect) Jun 20, 2025 5:42pm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Major refactoring of the translation system across all packages, moving from JSX-based content translation to ICU message format while optimizing data structures and improving type safety.

  • Introduces intl-messageformat integration in packages/core/src/formatting/format.ts for standardized message handling
  • Deprecates JSX translation in favor of ICU format, moving related code to /deprecated directory
  • Adds dedicated translation status tracking separate from content in provider components
  • Upgrades core package to v7.0.0-alpha.13, react to v10.0.0-alpha.13 with breaking changes
  • Improves hash generation by replacing hashJsxChildren with more generic hashSource function

76 files reviewed, 26 comments
Edit PR Review Bot Settings | Greptile

children?: any;
name?: string;
}): React.JSX.Element {
function Var({ children }: { children?: any }): React.JSX.Element | null {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: consider using React.ReactNode instead of any for children type to improve type safety

@@ -10,6 +10,7 @@ import {
} from 'generaltranslation/internal';
import { createUnsupportedLocalesWarning } from '../../errors/createErrors';
import { getSupportedLocale } from '@generaltranslation/supported-locales';
import { GT } from 'generaltranslation';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The GT import is not used anywhere in this file. Remove unused import.

Comment on lines +1 to +8
export class GTTranslationError extends Error {
constructor(
public error: string,
public code: number
) {
super(error);
this.code = code;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: constructor is reassigning public parameter 'code' unnecessarily - it's already auto-assigned via the parameter modifier 'public'

Suggested change
export class GTTranslationError extends Error {
constructor(
public error: string,
public code: number
) {
super(error);
this.code = code;
}
export class GTTranslationError extends Error {
constructor(
public error: string,
public code: number
) {
super(error);
}

Comment on lines +28 to +32
children: number | string | null | undefined;
name?: string;
options?: Intl.NumberFormatOptions;
locales?: string[];
}): React.JSX.Element {
}): React.JSX.Element | null {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: name prop is defined in type but never used in component parameters. Either remove from type definition or add to parameters if needed.

Suggested change
children: number | string | null | undefined;
name?: string;
options?: Intl.NumberFormatOptions;
locales?: string[];
}): React.JSX.Element {
}): React.JSX.Element | null {
children: number | string | null | undefined;
options?: Intl.NumberFormatOptions;
locales?: string[];

children?: any;
name?: string;
}): React.JSX.Element {
function Var({ children }: { children?: any }): React.JSX.Element | null {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Return type now includes null but component never returns null. Either remove null type or implement null return case.

Comment on lines +37 to +39
const result = gt
.formatDateTime(children, { locales, ...options })
.replace(/[\u200F\u202B\u202E]/g, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider extracting regex for bidirectional character removal into a named constant for better maintainability

* @param {Intl.NumberFormatOptions} [options={}] - Optional formatting options for the number, following `Intl.NumberFormatOptions` specifications.
* @returns {JSX.Element} The formatted number component.
* @returns {React.JSX.Element} The formatted number component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Return type documentation is incorrect - should include null since component can return null

Suggested change
* @returns {React.JSX.Element} The formatted number component.
* @returns {React.JSX.Element | null} The formatted number component.

Comment on lines +37 to 39
let renderedValue: string | number =
typeof children === 'string' ? parseFloat(children) : children;
if (typeof renderedValue === 'number') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: parseFloat could return NaN which isn't handled. Should add NaN check before formatting

@@ -18,7 +15,6 @@ import { RuntimeTranslationOptions } from 'gt-react/internal';
*
* @param {string} content - The content string that needs to be translated.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: param name in JSDoc is 'content' but function uses 'message'

Suggested change
* @param {string} content - The content string that needs to be translated.
* @param {string} message - The content string that needs to be translated.

translation: TranslationSuccess | TranslationLoading | TranslationError
): boolean {
translation: TranslatedChildren
) {
if (!(locale && hash && translation)) return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: setTranslations returns false but the return type is not specified in function signature

Suggested change
if (!(locale && hash && translation)) return false;
setTranslations(
locale: string,
hash: string,
translation: TranslatedChildren
): boolean {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants