Generalize the report EN/עב language toggle and useReportLang hook

Abierto
#5,241 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Refactorización
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
react, typescript

Línea de trabajo

The proposed files are packages/client/src/components/screens/reports/depreciation-report/report-lang-toggle.tsx and use-report-lang.ts; first read those changes in PR #5232 and the depreciation i18n.ts. Compare the landing page's landing-i18n.tsx and landing-nav.tsx to decide whether its localStorage-based language state should use the shared toggle. Migrate the depreciation report while preserving ?lang=he, replace navigation and coexistence with depreciationReportFilters, then run the existing tests from #5232.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Context

PR https://github.com/Urigo/accounter-fullstack/pull/5232 adds an EN | עב toggle to the depreciation report screen, plus a hook that keeps the language in the ?lang= URL param. Both are typed to the depreciation module and cannot be reused as they are. Other screens already have bilingual output, so the toggle and hook should be shared.

Files (as added by #5232):

  • packages/client/src/components/screens/reports/depreciation-report/report-lang-toggle.tsx: ReportLangToggle. The options are hard-coded to EN and עב, and the type comes from the depreciation i18n.ts.
  • packages/client/src/components/screens/reports/depreciation-report/use-report-lang.ts: useReportLang. It uses parseReportLang and REPORT_LANG_QUERY_PARAM from the depreciation i18n.ts.

Existing bilingual code to account for

  • Landing page (packages/client/src/components/landing/): LandingLangProvider in landing-i18n.tsx keeps the language in React context backed by localStorage (Hebrew default). Its toggle is inline in landing-nav.tsx. This is a different mechanism from the URL-based hook.
  • BilingualLabel (reports/securities-semi-annual-report/declaration-line.tsx): a label component with no state. It is not a toggle.
  • RTL wrappers (dir="rtl" / lang="he") in shaam-6111-report/*, form-1214-report/declarations-editor.tsx, securities-semi-annual-report/* and business/israeli-corporation-lookup.tsx: per-screen, with no shared switch.

Proposed work

  1. Move a generic toggle to a shared location (e.g. components/ui or components/common). Take the options and labels as props, and make the language type a generic parameter.
  2. Parameterize the hook by query param name and default value, so each screen can keep its own param.
  3. Migrate the depreciation report to the shared pieces, with no change in behavior or tests.
  4. Evaluate the landing page's LandingLangProvider as a second consumer. Its persistence (localStorage) differs from URL state, so decide whether to unify or keep both.
  5. Adopt the shared toggle only on screens that have a language switch. The RTL-only screens do not need it.

Acceptance criteria

  • The depreciation report's URL behavior is unchanged: ?lang=he works, navigation uses replace, and the hook coexists with the depreciationReportFilters param.
  • Existing tests from #5232 still pass.

Notes

Depends on #5232 merging first, since the files it describes exist only on that PR's branch.

Lenguaje dominante
TypeScript
Estrellas
30
Forks
10
Merge medio
2 d 12 h
PR fusionados (30 d)
276

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Urigo/accounter-fullstack

Todos los issues de Urigo/accounter-fullstack

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.