Giter VIP home page Giter VIP logo

Comments (4)

grawk avatar grawk commented on September 1, 2024

I'm pretty sure you don't need to customize formatPath. That is only responsible for the filesystem lookup of properties files based on the bcp47-style locale object.

I'm working through an example to see if I can give you a good recommendation for your use case.

from makara.

grawk avatar grawk commented on September 1, 2024

What do you think about using dynamic partial naming as described here: https://github.com/linkedin/dustjs/wiki/Dust-little-less-know-language-constructs#dynamic-partials

Then you'd have something like this:

/templates
    index.dust
    /partials
        myview-US.dust
        myview-GB.dust

And properties structure:

/locales
    /GB
        /en
            myview-GB.properties
    /US
        /en
            myview-GB.properties
            myview-US.properties

You would want to have all possible properties files defined in your default locale (en-US) and then override properties files per applicable locale.

from makara.

Noyabronok avatar Noyabronok commented on September 1, 2024

Thanks Matt.

The application already implements dynamic partials exactly as you describe. However, I don't understand why we need/want a /US/en/myview-GB.properties file when the path clearly states that the country is US. I am not crazy about having the country code as part of the filenames, especially in properties files.

I think it would be cleaner if there would be a single property file per locale, and that the property filename not specify any additional country codes. For dust files the country code is needed to differentiate the template, but I think it's better to place the code in the folder path instead of filename. Both ideas are in my original post example.

Thank you!

from makara.

grawk avatar grawk commented on September 1, 2024

If you're already dynamically selecting partials from the directory structure you've outlined, then you should just be able to use the useContent helper to select the appropriate properties file.

E.g.

/templates/US/myview.dust

{@useContent bundle="myview.properties"}

...

{/useContent}

You will have to add the argument to dust-makara-helpers to not infer the properties name/location from the template name/location:

config.json (typical)

"dust": {
        "helpers": [
            {
                "name": "dust-makara-helpers",
                "arguments": { "autoloadTemplateContent": false }
            }
        ]
    },

from makara.

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.