Giter VIP home page Giter VIP logo

Comments (5)

mikesparr avatar mikesparr commented on September 1, 2024

@jeffharrell is there no way within Controller to access language bundle to match a key value for current locale to a dynamic object returned from DB?

screen shot 2014-04-08 at 9 06 58 am

Say I have a Lucene search that includes facets with stats I want to update in sparklines as pages load, and sparkline file is include. I need sparkline file to be able to iterate through list of objects in model with stat count, list of bars, and a label to dynamically build 2 - 5 of these sparklines. The counts are okay but the label needs to match a key in bundle for current locale. I cannot seem to find a way to get this to work without hard-coding templates and lose the ability to just include a dynamic sparkline file that accepts list and renders mini stats.

Example model

        stats: [
            {key:'mini_stats.available', style:'sparkline_bar_good', value:'35', bars:[2,4,9,7,12,10,12]},
            {key:'mini_stats.sold_this_month', style:'sparkline_bar_neutral', value:'12', bars:[2,4,9,7,12,10,12]}
        ], 

Problem is even if I include key values matching bundle properties, since bundles evaluated at build time I'm unable to dynamically build this row of sparklines with the label for each stat. I cannot seem to find a way to render this content dynamically on the page and match language bundle key.

Goal would be to have a dust template that iterates through {#stats}<sparkline code here>{/stats} and could either evaluate the key sent from Model, or perhaps on Controller it can match keys and load proper label (i.e. Available, Sold This Mo, etc.).

Idea would be that the model includes label Available, Sold This Mo coming from facet filter results corresponding to counts and histograms. These are part of stats model list. The template could then do a Map lookup in bundle to match key {@pre type="content" key="miniStats[{label}]" /}. Since @pre only works at build time, is there a way to access at runtime or custom helper that could accomplish this?

from makara.

mikesparr avatar mikesparr commented on September 1, 2024

@jeffharrell I built a helper to solve the issue short term and sharing on my personal page at: https://github.com/mikesparr/Kraken_Example_i18n_Helper

I'll keep my eyes open if you solve dynamically matching keys in Controller or have a better way to do this but hopefully this will help others in short term. Feel free to share, take, etc.

from makara.

aredridel avatar aredridel commented on September 1, 2024

We're moving away from build-time localization of templates, so this will be moot in the new design.

from makara.

brakon avatar brakon commented on September 1, 2024

What will be the new design without build-time localization?

from makara.

aredridel avatar aredridel commented on September 1, 2024

Templates will include @pre (deprecated), @message (backward-compatible) or @formatMessage (via formatjs.io project) helpers, and you can plug in a language bundle resolver that will supply bundles of strings. At the moment, that means loading a language-specific <script> tag with the actual strings, in addition to the javascript bundle of your app.

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.