Ya that is needed but, that is too much work for the app dev, for the template usecase. So we need a convenient way. Ideally if you have {{i18n "key"}} hbs, it should automatically work same as in backbend UUF. This means we have to write a js helper, and inside that we can use the above API you propose.
As a implementation detail, we should use a simple key-value json API, just like the lib chanaka mentions, so we have the option to switch if needed. On Fri, Mar 24, 2017 at 10:26 AM, SajithAR Ariyarathna <sajit...@wso2.com> wrote: > There are some usecase where web app developers need client-side i18n. > > IMO, we can give this capability through UUF Client library. > > UUFClient.i18n("message.key"); // value of the Accept-Language header will be > used to compute locale > UUFClient.i18n("message.key", parameters[]); > UUFClient.i18n("message.key", parameters[], "en-AU"); // use the specified > locale > > > UUFClient will do whatever needs to get the translated string, so the > webapp developer doesn't need to worry about calling some REST API or > sending i18n language files to client-side. > > > On Fri, Mar 24, 2017 at 2:10 PM, Nuwandi Wickramasinghe <nuwan...@wso2.com > > wrote: > >> >> >> On Fri, Mar 24, 2017 at 1:49 PM, Nuwan Dias <nuw...@wso2.com> wrote: >> >>> >>> >>> On Fri, Mar 24, 2017 at 1:23 PM, Ruwan Abeykoon <ruw...@wso2.com> wrote: >>> >>>> Hi All, >>>> What if, >>>> i18n is handled on the server side only, and encode the relevant >>>> localized strings into HTML by the server-side (js or hbs). >>>> Client side libraries only read the string values already in the client >>>> locale within HTML DOM itself and just render the data. No client-side >>>> i18n. >>>> >>> I have a situation where a part of the DOM is created in client side JS. >> In that case this wouldn't work. >> >>> >>>> What is would be the limitations? >>>> >>> >>> Limitations would be for SPAs where the rendering is done at the client >>> side. Which would basically mean that SPAs can't have localization. >>> >>>> >>>> Cheers, >>>> Ruwan >>>> >>>> On Fri, Mar 24, 2017 at 11:54 AM, Nipuna Chandradasa <nipu...@wso2.com> >>>> wrote: >>>> >>>>> API of somekind(Rest or a http service endpoint), That we have to >>>>> think about, that exposes a functionality to retrieve i18n as a json >>>>> object to layout level or any other global level of the application. So on >>>>> client side we can use the i18n language details anywhere. >>>>> We can get the language data from the browser.. that's how we do it >>>>> anyway i think. We get the i18n based on the what language browser has >>>>> configured to use. >>>>> >>>>> Thank you, >>>>> >>>>> On Fri, Mar 24, 2017 at 10:14 AM, Prasanna Dangalla <prasa...@wso2.com >>>>> > wrote: >>>>> >>>>>> On Fri, Mar 24, 2017 at 12:53 AM, Nipuna Chandradasa < >>>>>> nipu...@wso2.com> wrote: >>>>>> >>>>>>> I don't think there is a feasible solution rather than loading i18n >>>>>>> config file as a json object to the client side in the beginning of the >>>>>>> app... i think from uuf side we can provide a api for that... WDYT? >>>>>>> >>>>>> API in the sense, what kind of an API ? Does this loads all the data >>>>>> into front end or are you thinking about a filtering mechanism for the >>>>>> language data by page before you send them to front end ? >>>>>> >>>>>> >>>>>> On Thu, Mar 23, 2017 at 5:29 PM, SajithAR Ariyarathna < >>>>>> sajit...@wso2.com> wrote: >>>>>> >>>>>>> Currently UUF doesn't support i18n in client-side. >>>>>>> >>>>>>> @UUF Team, >>>>>>> We need to come up with a solution for client-side i18n. Shall we >>>>>>> start a discussion on this? >>>>>>> >>>>>>> Thanks. >>>>>>> >>>>>>> >>>>>>> On Thu, Mar 23, 2017 at 4:36 PM, Prasanna Dangalla < >>>>>>> prasa...@wso2.com> wrote: >>>>>>> >>>>>>>> Hi Sajith, >>>>>>>> >>>>>>>> This is for Client-side JS >>>>>>>> >>>>>>>> *Prasanna Dangalla* >>>>>>>> Senior Software Engineer, WSO2, Inc.; http://wso2.com/ >>>>>>>> lean.enterprise.middleware >>>>>>>> >>>>>>>> >>>>>>>> *cell: +94 718 11 27 51* >>>>>>>> *twitter: @prasa77* >>>>>>>> >>>>>>>> On Thu, Mar 23, 2017 at 2:54 PM, SajithAR Ariyarathna < >>>>>>>> sajit...@wso2.com> wrote: >>>>>>>> >>>>>>>>> Hi Prasanna, >>>>>>>>> >>>>>>>>> Is there a mechanism defined to use something like i18n in >>>>>>>>>> javascript ? >>>>>>>>> >>>>>>>>> Server-side JS or Client-side JS? >>>>>>>>> >>>>>>>>> On Thu, Mar 23, 2017 at 11:02 AM, Ayesha Dissanayaka < >>>>>>>>> aye...@wso2.com> wrote: >>>>>>>>> >>>>>>>>>> Hi Prasanna, >>>>>>>>>> >>>>>>>>>> Similar discussion was started sometime back in [1]. >>>>>>>>>> Issues in [2], [3] have some suggestions. >>>>>>>>>> >>>>>>>>>> [1] [Dev][UUF][IS-6] Enable i18n support in javascript >>>>>>>>>> [2] https://github.com/wso2/carbon-uuf/issues/160 >>>>>>>>>> [3] https://github.com/wso2/carbon-uuf/issues/166 >>>>>>>>>> >>>>>>>>>> @Ayesha: As I understood all these are done for server side JS, >>>>>>>> I'm wondering about client side JS. >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>>> On Thu, Mar 23, 2017 at 10:46 AM, Pubudu Gunatilaka < >>>>>>>>>> pubu...@wso2.com> wrote: >>>>>>>>>> >>>>>>>>>>> Adding Manu and Sajith. >>>>>>>>>>> >>>>>>>>>>> On Thu, Mar 23, 2017 at 10:44 AM, Prasanna Dangalla < >>>>>>>>>>> prasa...@wso2.com> wrote: >>>>>>>>>>> >>>>>>>>>>>> Hi Nisala, >>>>>>>>>>>> >>>>>>>>>>>> I was wondering how to include this in javascript files, not in >>>>>>>>>>>> hbs files. Is there a way to include in javascrip fiels ? >>>>>>>>>>>> >>>>>>>>>>>> Thanks >>>>>>>>>>>> >>>>>>>>>>>> *Prasanna Dangalla* >>>>>>>>>>>> Senior Software Engineer, WSO2, Inc.; http://wso2.com/ >>>>>>>>>>>> lean.enterprise.middleware >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> *cell: +94 718 11 27 51* >>>>>>>>>>>> *twitter: @prasa77* >>>>>>>>>>>> >>>>>>>>>>>> On Thu, Mar 23, 2017 at 10:33 AM, Nisala Nanayakkara < >>>>>>>>>>>> nis...@wso2.com> wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Hi Prasanna, >>>>>>>>>>>>> >>>>>>>>>>>>> UUF has the capability of facilitating above mentioned >>>>>>>>>>>>> scenario. You can define your language property file under the >>>>>>>>>>>>> ‘lang’ >>>>>>>>>>>>> directory as follows. >>>>>>>>>>>>> >>>>>>>>>>>>> |----src >>>>>>>>>>>>> | |----main >>>>>>>>>>>>> | |---- pages/ >>>>>>>>>>>>> | |---- fragments/ >>>>>>>>>>>>> | |---- layouts/ >>>>>>>>>>>>> | |---- modules/ >>>>>>>>>>>>> | |---- lang/ >>>>>>>>>>>>> |----en_US.properties >>>>>>>>>>>>> | |---- public/ >>>>>>>>>>>>> >>>>>>>>>>>>> After that you can use following code segment to achieve your >>>>>>>>>>>>> requirement in your hbs file. >>>>>>>>>>>>> >>>>>>>>>>>>> {{i18n "my.sample.key"}} >>>>>>>>>>>>> >>>>>>>>>>>>> Please go through sample app available here[1] if you need >>>>>>>>>>>>> more clarification. Moreover you can find actual usage above code >>>>>>>>>>>>> segment >>>>>>>>>>>>> here[2] and corresponding language file here[3]. >>>>>>>>>>>>> >>>>>>>>>>>>> [1] - https://github.com/wso2/carbon >>>>>>>>>>>>> -uuf/tree/master/samples/apps/org.wso2.carbon.uuf.sample.pet >>>>>>>>>>>>> s-store.app >>>>>>>>>>>>> [2] - https://github.com/wso2/carbon >>>>>>>>>>>>> -uuf/blob/master/samples/apps/org.wso2.carbon.uuf.sample.pet >>>>>>>>>>>>> s-store.app/src/main/pages/index.hbs#L16 >>>>>>>>>>>>> [3] - https://github.com/wso2/carbon >>>>>>>>>>>>> -uuf/blob/master/samples/apps/org.wso2.carbon.uuf.sample.pet >>>>>>>>>>>>> s-store.app/src/main/lang/en_US.properties >>>>>>>>>>>>> >>>>>>>>>>>>> Thanks, >>>>>>>>>>>>> Nisala >>>>>>>>>>>>> >>>>>>>>>>>>> On Thu, Mar 23, 2017 at 9:01 AM, Prasanna Dangalla < >>>>>>>>>>>>> prasa...@wso2.com> wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Hi Devs, >>>>>>>>>>>>>> >>>>>>>>>>>>>> Is there a mechanism defined to use something like i18n in >>>>>>>>>>>>>> javascript ? Does the UUF has the capability of facilitating >>>>>>>>>>>>>> this ? You >>>>>>>>>>>>>> inputs are highly appreciated. >>>>>>>>>>>>>> >>>>>>>>>>>>>> Thanks >>>>>>>>>>>>>> >>>>>>>>>>>>>> *Prasanna Dangalla* >>>>>>>>>>>>>> Senior Software Engineer, WSO2, Inc.; http://wso2.com/ >>>>>>>>>>>>>> lean.enterprise.middleware >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>>> *cell: +94 718 11 27 51* >>>>>>>>>>>>>> *twitter: @prasa77* >>>>>>>>>>>>>> >>>>>>>>>>>>>> _______________________________________________ >>>>>>>>>>>>>> Dev mailing list >>>>>>>>>>>>>> Dev@wso2.org >>>>>>>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> -- >>>>>>>>>>>>> *Nisala Niroshana Nanayakkara,* >>>>>>>>>>>>> Software Engineer >>>>>>>>>>>>> Mobile:(+94)717600022 >>>>>>>>>>>>> WSO2 Inc., http://wso2.com/ >>>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> _______________________________________________ >>>>>>>>>>>> Dev mailing list >>>>>>>>>>>> Dev@wso2.org >>>>>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> -- >>>>>>>>>>> *Pubudu Gunatilaka* >>>>>>>>>>> Committer and PMC Member - Apache Stratos >>>>>>>>>>> Software Engineer >>>>>>>>>>> WSO2, Inc.: http://wso2.com >>>>>>>>>>> mobile : +94774078049 <%2B94772207163> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> _______________________________________________ >>>>>>>>>>> Dev mailing list >>>>>>>>>>> Dev@wso2.org >>>>>>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> *Ayesha Dissanayaka* >>>>>>>>>> Senior Software Engineer, >>>>>>>>>> WSO2, Inc : http://wso2.com >>>>>>>>>> <http://www.google.com/url?q=http%3A%2F%2Fwso2.com&sa=D&sntz=1&usg=AFQjCNEZvyc0uMD1HhBaEGCBxs6e9fBObg> >>>>>>>>>> 20, Palm grove Avenue, Colombo 3 >>>>>>>>>> E-Mail: aye...@wso2.com <ayshsa...@gmail.com> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Sajith Janaprasad Ariyarathna >>>>>>>>> Software Engineer; WSO2, Inc.; http://wso2.com/ >>>>>>>>> <https://wso2.com/signature> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Sajith Janaprasad Ariyarathna >>>>>>> Software Engineer; WSO2, Inc.; http://wso2.com/ >>>>>>> <https://wso2.com/signature> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Dev mailing list >>>>>>> Dev@wso2.org >>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> >>>>>>> Nipuna Marcus >>>>>>> *Software Engineer* >>>>>>> WSO2 Inc. >>>>>>> http://wso2.com/ - "lean . enterprise . middleware" >>>>>>> Mobile : +94 (0) 713 667906 <+94%2071%20366%207906> >>>>>>> nipu...@wso2.com >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Dev mailing list >>>>>>> Dev@wso2.org >>>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Nipuna Marcus >>>>> *Software Engineer* >>>>> WSO2 Inc. >>>>> http://wso2.com/ - "lean . enterprise . middleware" >>>>> Mobile : +94 (0) 713 667906 <+94%2071%20366%207906> >>>>> nipu...@wso2.com >>>>> >>>>> _______________________________________________ >>>>> Dev mailing list >>>>> Dev@wso2.org >>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>>> >>>>> >>>> >>>> >>>> -- >>>> >>>> *Ruwan Abeykoon* >>>> *Associate Director/Architect**,* >>>> *WSO2, Inc. http://wso2.com <https://wso2.com/signature> * >>>> *lean.enterprise.middleware.* >>>> >>>> >>>> _______________________________________________ >>>> Dev mailing list >>>> Dev@wso2.org >>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>> >>>> >>> >>> >>> -- >>> Nuwan Dias >>> >>> Software Architect - WSO2, Inc. http://wso2.com >>> email : nuw...@wso2.com >>> Phone : +94 777 775 729 <+94%2077%20777%205729> >>> >>> _______________________________________________ >>> Dev mailing list >>> Dev@wso2.org >>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>> >>> >> >> >> -- >> >> Best Regards, >> >> Nuwandi Wickramasinghe >> >> Software Engineer >> >> WSO2 Inc. >> >> Web : http://wso2.com >> >> Mobile : 0719214873 >> >> _______________________________________________ >> Dev mailing list >> Dev@wso2.org >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > Sajith Janaprasad Ariyarathna > Software Engineer; WSO2, Inc.; http://wso2.com/ > <https://wso2.com/signature> > > _______________________________________________ > Dev mailing list > Dev@wso2.org > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- With regards, *Manu*ranga Perera. phone : 071 7 70 20 50 mail : m...@wso2.com
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev