Back

[Solved] Best Practices for Localizing Content in AppWrite Database

  • 1
  • Databases
Bagios
26 Aug, 2024, 15:38

Hi AppWrite Community,

I'm working on a project that requires supporting multiple languages for a variety of content stored in the AppWrite database. Specifically, I need to localize several fields such as names, descriptions, and user-generated content across different collections.

I've considered using nested fields for each language, like this:

TypeScript
{
    "$id": "example_document",
    "name": {
        "en": "Example Name",
        "it": "Nome Esempio",
        "es": "Nombre Ejemplo"
    },
    "description": {
        "en": "Example description in English.",
        "it": "Descrizione di esempio in italiano.",
        "es": "Descripción de ejemplo en español."
    }
}

However, this approach seems to require creating new collections or nested fields for every field that needs localization, which can become complex and hard to manage as the number of supported languages and the volume of content grow.

Questions:

  1. What are the best practices for efficiently storing and querying localized content in AppWrite without creating new collections for every localized field?
  2. Are there any built-in features that facilitate content localization in AppWrite?
  3. How do you handle indexing and querying performance when dealing with multiple languages in a single collection?
  4. Are there any common pitfalls or challenges to be aware of when implementing localization in AppWrite, and how can they be mitigated?

Any insights, examples, or experiences you can share would be greatly appreciated!

Thanks in advance for your help!

TL;DR
Developers discussing best practices for localizing content in AppWrite database. Proposed solution includes adding a new custom field to identify language in each document. No need for creating new collections, just new documents for each language. They can optimize management this way.
Bagios
27 Aug, 2024, 08:27

No one? 😦

ideclon
27 Aug, 2024, 08:40
  1. I’m not sure why you’d be creating new Collections for each field here? It looks like you’d just want to create a new Document for each field.

I would probably have a new Document for every language of every field. So each document would hold a field ID, the language code and the string.

  1. Not as far as I’m aware.
  2. You can create Indexes in Appwrite, which behind the scenes are just MariaDB indexes.
  3. I’m not aware of anyone who’s actually done this with Appwrite, but practically, there shouldn’t be any Appwrite specific challenges here
Bagios
27 Aug, 2024, 08:53

Thanks for the explanation. I think your proposal makes a lot of sense, so I will probably add a new custom field to identify the language of every document. This means having multiple documents for every language, but it will optimize how they are managed.

ideclon
27 Aug, 2024, 09:06

Np. If your issue has been solved, you can mark this post as closed by adding "[SOLVED]" to the beginning of the title

Bagios
27 Aug, 2024, 09:22

[Solved] Best Practices for Localizing Content in AppWrite Database

Johann V.
17 Oct, 2024, 03:15

Hi there, I'd like to validate I understand your solution. So, in your case, you will have 3 documents? 1. "example_document_en", 2. "example_document_it", 3. "example_document_es"? And within each document a new field inside identifying the language, like "lang" = 'es' for the first document, and 'it' for the second, and 'es' for the last? This is the solution I'm actually considering for my project, that's why I'd like to validate with your idea and experience, if possible! Thanks a lot.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more