Giter VIP home page Giter VIP logo

Comments (10)

tomxor avatar tomxor commented on June 2, 2024

By default Vault picks up the default locale of the space. When performing sync you can pass Vault a custom locale:

Vault.with(context, YourSpace.class).requestSync(SyncConfig.builder()
    .setClient(client)
    .setLocale("CODE")
    .build());

This however results in re-syncing the entire space, invalidating any existing data.

I think it's a good idea to persist all the locales though, as that allows switching locales while in offline mode. We can look into doing that soon.

Can you elaborate on your last point? (re the previous language not being completely removed) - one thing that might throw you off is this: contentful/contentful.java#85

from vault.

davetao avatar davetao commented on June 2, 2024

Thanks @tomxor , appreciate the fast replies. If it can be supported it would be fantastic. Will it take very long to make this enhancement to the vault library?

At the moment, my only solution is to use the contentful.java SDK to persist the different languages, it would be a shame to do that because you have written such an excellent library with the built in ORM

To answer the last point, I did a test where I downloaded content for English first. I then changed the locale in a later build and checked the data. I shall look into it a bit further and create a new ticket if i can write a test for it.

from vault.

tomxor avatar tomxor commented on June 2, 2024

We can definitely look into implementing this feature soon. The way to do that would probably be (as you suggested) having multiple SQLite files for the same space, and providing a way to specify the locale when making queries:

vault.fetch(Foo.class).all("en-US");
vault.fetch(Foo.class).first("en-US");

vault.fetch(Foo.class).all(); // should use the default locale

Unfortunately I'm traveling this week and will only be able to attend to this next week, however we'll do our best to push this out quickly.

from vault.

davetao avatar davetao commented on June 2, 2024

Thanks again. Look forward to the results. Also, thanks for the Rx support for the orm as well. Its working very well

from vault.

tomxor avatar tomxor commented on June 2, 2024

Thanks for the feedback! :)

from vault.

tomxor avatar tomxor commented on June 2, 2024

Having another look at this it seems that multiple SQLite files might not be the best solution, since we will end up caching (potentially) lots of SQLiteOpenHelper instances + connections, which means a much bigger memory footprint. We might be able to avoid this by just using multiple tables within one database file.

from vault.

davetao avatar davetao commented on June 2, 2024

I would agree with that perspective. I suppose the database tables would be prefixed with the locale name as well?

from vault.

tomxor avatar tomxor commented on June 2, 2024

Yap, I already have this implemented on a local branch, should probably manage to submit a PR tomorrow and :shipit:

For every model the table name format is:

entry_{content_type_id_hash}${locale}

same applies for assets:

assets${locale}

and links:

links${locale}

This will be backwards-incompatible since the locales (at least one) must be explicitly defined with the @Space annotation:

@Space(value = "cfexampleapi", models = { ... }, locales = { "en-US", "tlh" })
class DemoSpace {
}

from vault.

davetao avatar davetao commented on June 2, 2024

Great enhancement. thanks again.

from vault.

tomxor avatar tomxor commented on June 2, 2024

@davetao Once again, your feedback is greatly appreciated. 🙇

from vault.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.