mathesar-foundation / mathesar

Web application providing an intuitive user experience to databases.
https://mathesar.org/
GNU General Public License v3.0
2.39k stars 332 forks source link

Move strings out of component library #3937

Open pavish opened 3 weeks ago

pavish commented 3 weeks ago

Description

The component library should not directly use svelte-i18n. We should handle the following:

seancolsen commented 3 weeks ago

I'm commenting to add some clarity because I was confused when I read the issue description.

Our component library doesn't currently import svelte-i18n. So no changes needed there.

The problem is that our component library currently has some strings which are hard-coded in English. For example, in FileUpload.svelte, we have:

<span>Uploaded {percentage}%</span>

and

<div class="title">Drag a file here</div>

I think what we need to do in this example is refactor that component to accept props for those strings, probably something like this:

export let i18nUploadedPercentage: (percentage: number) => string =
  (percentage) => `Uploaded ${percentage}%`;

export let i18nDragAFileHere: string = 'Drag a file here';

There are only a very small handful of places like this in the component library, with FileUpload.svelte being perhaps the most glaring example.