How do I get rid of this mozL10n.get()?

So I have a few strings that contains arguments that also needs to be translated
https://github.com/mozilla-b2g/gaia/blob/42e93d96ea245c778885b1889b3da589f5342fb1/apps/keyboard/locales/keyboard.en-US.properties#L77

And at the time of writing the code I ended up using mozL10n.get().

https://github.com/mozilla-b2g/gaia/blob/42e93d96ea245c778885b1889b3da589f5342fb1/apps/keyboard/js/settings/layout_item_view.js#L263-L265

Do we already have support on this? The answer is probably obvious if
there is already one.

The status itself is one <span> element which I prefer not to break
into multiple elements.

(Sorry for the spam coz it's hard to find people on irc on my timezone)


Tim
0
Tim
5/3/2015 3:22:33 AM
mozilla.dev.gaia 3196 articles. 0 followers. Post Follow

4 Replies
1055 Views

Similar Articles

[PageSpeed] 35

There's the replace the sync .get with an async promise formatValue(), 
https://github.com/mozilla-b2g/gaia/blob/8ac420f37409a4d026eb5731c48ed5b12bbf2d4c/shared/elements/gaia_menu/script.js#L30 
has an example. Guess you'd had to wrap those once or twice.

Alternatives, more work and some more future:

In classic mode, a string per unit would fix this. Also, see my favorite 
https://bugzilla.mozilla.org/show_bug.cgi?id=945040, about Bytes and plural.

In l20n mode, just pass in the unit as a param, and let the localization 
deal with it. Which is me giving a sneak preview that we'll soon be able 
to use some set of l20n proper in gaia.

Which is me saying that I'm not sure this use-case is in our basic set 
:-( . Bad Bytes, which likely need proper handling.

Axel

On 5/3/15 5:22 AM, Tim Guan-tin Chien wrote:
> So I have a few strings that contains arguments that also needs to be translated
> https://github.com/mozilla-b2g/gaia/blob/42e93d96ea245c778885b1889b3da589f5342fb1/apps/keyboard/locales/keyboard.en-US.properties#L77
>
> And at the time of writing the code I ended up using mozL10n.get().
>
> https://github.com/mozilla-b2g/gaia/blob/42e93d96ea245c778885b1889b3da589f5342fb1/apps/keyboard/js/settings/layout_item_view.js#L263-L265
>
> Do we already have support on this? The answer is probably obvious if
> there is already one.
>
> The status itself is one <span> element which I prefer not to break
> into multiple elements.
>
> (Sorry for the spam coz it's hard to find people on irc on my timezone)
>
>
> Tim
>

0
Axel
5/3/2015 7:52:31 AM
As Axel said, for now, the best thing is to turn it to async with formatValue. The not-relying-on-sync is the big switch.

Once we land l20n format [0] you will do:

l20n:

<byteUnit {
  B: 'Bytes',
  KB: 'KB',
  MB: 'MB',
  GB: 'GB'
}>
<preInstalledStatus "{{ $size }} {{ byteUnit[$unit] }}">

and in js:

navigator.mozL10n.setAttributes(node, 'preInstalledStatus', {
  'size': 234,
  'unit': 'B'
}>

zb.

[0] https://bugzilla.mozilla.org/show_bug.cgi?id=1027684
0
Zibi
5/3/2015 11:08:40 PM
On Mon, May 4, 2015 at 7:08 AM, Zibi Braniecki
<zbigniew.braniecki@gmail.com> wrote:
> As Axel said, for now, the best thing is to turn it to async with formatValue. The not-relying-on-sync is the big switch.

Thanks for the response Zibi and Axel!

This is sad. To convert the said part into async means I would need to
ensure the right order of callback execution, so the old status will
not overwrite the new one.

Even if the order is guaranteed in the current l10n implementation, it
would still be better to defend that in the code as I don't know what
the future implementation will behave.

(With Promises controlling the order probably always means pushing
every promise into a queue. It's a bit ugly but it's way better than
callback with flags though.)
0
Tim
5/4/2015 2:55:07 AM
On Sunday, May 3, 2015 at 10:55:32 PM UTC-4, Tim Guan-tin Chien wrote:
> On Mon, May 4, 2015 at 7:08 AM, Zibi Braniecki
> > As Axel said, for now, the best thing is to turn it to async with formatValue. The not-relying-on-sync is the big switch.
> 
> Thanks for the response Zibi and Axel!
> 
> This is sad. To convert the said part into async means I would need to
> ensure the right order of callback execution, so the old status will
> not overwrite the new one.

I agree. My guess is that it's better to leave this particular mozL10n.get use for now then, and switch this resource to l20n format once we land support for it.

I expect us to land the parser itself within the next month or so. Let's revisit then!

In the meantime, there are hundreds of other uses of mozL10n.get that can be migrated now :)

zb.
0
Zibi
5/4/2015 1:18:24 PM
Reply:

Similar Artilces:

POST GET GET GET GET... WTH?
Hi, I'm at a loss to explain this... I have an ASPX page that I can't always navigate to. When I developed the app (it's Starter Kit Portal-based), I did it on my LAN and have had no trouble accessing the page. However, upon deployment, I see the following behavior: 1. POST request goes out looking for MyForm.aspx 2. GET request for MyForm.aspx 3. GET request for MyForm.aspx 4. ... X. GET request Sometimes, the page finally loads. Other times, it just ends up blank. Many times, it doesn't load at ALL the first POST - I just get a "The pa...

Get rid of SM email or I get rid of browser!
I use Windows 7 and am FED UP with SM 2.0's demanding that I use its email client! I want the BROWSER ONLY. I've been using Pegasus Mail as my client since 1994 and wont stop. Yet something wont allow me to make that my default email client in SM, it opens SM's mail client for any email link I click on and wont allow it to be changed. I either get this to stop or I gotta find another browser, this is BULL! -- Jane Galt "There is no difference between communism and socialism, except in the means of achieving the same ultimate end: communism proposes t...

How do I get get rid of 2nd login
I work at a company that is on a Novell network. We all run Novell client for Windows V. 4.9(2 I think). What I want to do it to get rid of the second log in screen. There is the original Novell Client login, then it prompts me for my workstation username and password. There are other computers that do not ask for the workstation info, they just create an account based on the novell info. This is good if you want to map another network share in a workgroup or something. Does anybody know how to do this? On another note, this computers are most all shared, so simply clicking t...

get rid of that ridiculous getting started bookmark
Name: DOCTOR Product: Firefox Summary: get rid of that ridiculous getting started bookmark Comments: Browser Details: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.18 (KHTML, like Gecko) Version/3.1.2 Safari/525.22 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

Am getting a pop-up that I need help getting rid of
Name: David Heywood Email: dave.heywood_at_heywoodrealty.com Product: Firefox Summary: Am getting a pop-up that I need help getting rid of Comments: A stupid pop window advertising all kinds of junk keeps popping up that has never popped up before. Can you guys help me figure out where it has planted itself so I can get rid of it. The title line in the box says "Aurora - part of the ABI Network" Thanks Dave Heywood dave.heywood@heywoodrealty.com Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3 ...

Two things,Why do I keep getting emails that I don't want. can't get rid of them? Why can't I get my email when I am out of town? Or can I?
Name: Ed Leech Email: ELCraftatzoominternetdotnet Product: Thunderbird Summary: Two things,Why do I keep getting emails that I don't want. can't get rid of them? Why can't I get my email when I am out of town? Or can I? Comments: I am getting frusted with all the emails coming in that I do not want, I am using the tools to get thme out but they keep coming. They just use different names or whatever. I have been thinking of just switching to something else but my business intrusts know this email and it is tooo confusing to change. Every time I go out of town on bu...

Get Rid of the Sneeky McAfee download that gets bundled
Name: Product: Firefox Summary: Get Rid of the Sneeky McAfee download that gets bundled Comments: Get Rid of the Sneeky McAfee download that gets bundled with the Adobe update, you can't see if then you have to go and delete it. Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11 ( .NET CLR 3.5.30729) From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

Getting rid of McAfee Site Advisor (& getting out of safe mode)
I've been having frequent Flash Plugin crashes, so I choose the Help option of restarting with all add-ons disabled, and when it came back up, it told me I was in safe mode. But there's no menu item for getting out of safe mode: why don't they have the same item in reverse: "restart with all add-ons enable"? But my real question is why McAfee Site Advisor shows as an add-on, even though Control Panel doesn't show it as an installed program (so I can't delete it). Worse, it's the only add-on that doesn't have a "remove" option. Why i...

How to get rid of url in parent node in web.sitemap without getting error when running the file.
Hello all. I need your tip to disable parent node in web.sitemap.  I use a TreeView and a SitemapDatasource in my application.   I have a Web.sitemap below. <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >  <siteMapNode url="~/Default.aspx" title="Home">  //this is the root.     <siteMapNode url="  " title="Error Ticket">  //this is parent node.  I look for the way to get rid of url here, but how?       ...

Getting variables from a post or get?
Sorry for the newbie post, but i am from a PHP world. Im now learning ASP.NET.Im having a bit of problem figuring out how to get/post a variable on an input field. All i want to do is, get the value from an input form and display it again on the page. Here's my code.. <form id="form1" runat="server" acceptcharset="utf-8"> Your name: <input id="name" name="name" type="text" /> <asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="Default.aspx" /> </form> All i want is to get the value of name and display it on the page it self. How can i do that...

Get All & Get all mail
Is there any difference between these two extensions? Daniel -- _____________________________________ Daniel Royer University of Geneva daniel at royer dot ch _Daniel Royer_ spoke thusly on 11/09/2006 4:31 AM: > Is there any difference between these two extensions? I can't seem to find a "Get All" extension for Thunderbird. The closest I've found is <http://extensionroom.mozdev.org/more-info.php/getmess>, which is not written to the extension manager API, that was implemented long before Thunderbird 1.0. If that's what you were referri...

Get LastLoginDate BEFORE it gets updated
I am after a way to get the LastLoginDate before it gets updated when a user logs on. The reason is that i want to provide a list of all changes that have been done since they last logged on. When i use OnLoggingIn it appears that the LastLoginDate has already been updated (with the new Login Date). I have tried numerous ways but am a little stumped.  Any help will be greatly appriciated. Try this -  Dim LastloginDate As Date Protected Sub Login1_LoggingIn(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) Handles Login1.LoggingIn ...

Get get HotSync to work
Hi, I'm having problems synchronizing my custom Ultra-Lite application. After a HotSync the log file looks as follows: HotSync operation started 11/06/01 03:47:36 PM Expense - sync configured to Do Nothing Outlook Calendar - sync configured to Do Nothing Outlook Contacts - sync configured to Do Nothing Outlook Tasks - sync configured to Do Nothing Outlook Notes - sync configured to Do Nothing Unable to open the stream 11/06/01 03:47:40 PM OK PalmTCS (Adaptive Server Anywhere Conduit) with 1 message(s) 11/06/01 03:47:40 PM OK System Yet, the MobilLink Server still says:...

How to get rid of
Name: Gary Schaefer Email: garylschathotmaildotcom Product: Thunderbird Summary: How to get rid of Comments: I started using Thunderbird as a mail client, but I switched to a different ISP server. I now use MSN Live. Every time I try to use a URL web mail address, I get Thunderbird as a mail server. I do not want this because I cannot send out any email. After I try to send the email, I get a message that it failed. I wish to get rid of this so when I try to use a URL web site mail it will go directly to MSN live mail. Thank you. Browser Details: Mozilla/5.0 (Windows; U; W...

Web resources about - How do I get rid of this mozL10n.get()? - mozilla.dev.gaia

Resources last updated: 12/25/2015 5:09:44 PM