Www.rust-lang.org: [meta] Add localization strings everywhere

Created on 23 May 2019  Â·  27Comments  Â·  Source: rust-lang/www.rust-lang.org

Part of https://github.com/rust-lang/www.rust-lang.org/issues/799

With https://github.com/rust-lang/www.rust-lang.org/pull/794 and https://github.com/rust-lang/www.rust-lang.org/pull/796 we have all of the infrastructure necessary to add localization strings everywhere.

If you're interested in helping, check out the i18n branch, pick an unclaimed file from the below list, and follow the instructions below.

Files needing creation (and all the template files they should contain info for):

Leave a comment if you're interested in picking up one of these!

A-i18n

All 27 comments

Instructions

Make sure you're working off the i18n branch (and making pull requests off of the i18n branch)

The way this works is that you take one of the handlebars files under templates/, and move all of their strings into a Fluent .ftl file. So, you start off with something like

# templates/pitch.hbs
<div>
<h2>The Rust programming language is super cool</h2>
<p>It is very very cool no seriously <a href="..">read more</a></p>
</div>

and turn it into

# templates/pitch.hbs
<div>
<h2>{{text pitch-header}}</h2>
<p>{{text pitch-blurb}}</p>
</div>
# templates/fluent-resource/en-US/pitch.ftl
pitch-header = The Rust programming language is super cool
pitck-blurb = It is very very cool no seriously <a href="..">read more</a>

Basically, go through every string in the file, give it an appropriate name, and move it into an FTL file under locales/en-US/. That folder already has FTL files that should give you an idea of what the names should look like. The Fluent ids live in a global namespace; make sure you namespace the ids. E.g if you're writing cli.hbs, name everything cli-foo-bar or something.

Note that multiline stuff works if you indent it, as in

something-something = Lorem ipsum dolor sit amet, consectetur adipiscing elit,
     sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
    ex ea commodo consequat. 

If you're interested, make sure you leave a comment picking an ftl file to create from the list in the issue body above. Making partial PRs -- where you've only stringified some of the stuff for a file -- is also fine.

Hi Manish, I'll start working on the tools.ftl file.

I'll assume that proper nouns like "Rustfmt" that are used as a title should be factored out as well.

@eignnx yes, that should be done too. All words, basically.

@eignnx note that the tools.ftl file already contains one line of test translation. Leave that as is. It's using textparams, but don't worry about that for now, we don't actually want to do that kind of thing in most cases.

@Manishearth any style preference for line-length in .ftl files? I see in teams.ftl body text tends to be on one line, as opposed to tools.ftl where body text is split onto multiple lines, as it is the HTML files.

teams.ftl is autogenerated. Split into multiple lines where you can. No hard limit, but I'd try to wrap at 80 or 100.

I'm now working on tools/install.hbs

@Manishearth for multi-paragraph sections, should each <p> contain it's own substitution variable:

<p>{{text x}}</p>
<p>{{text y}}</p>
<p>{{text z}}</p>

```
x = Paragraph 1 contents.
y = Paragraph 2 contents.
z = Paragraph 3 contents.

or could one variable contain all three `<p></p>` tags:

```html
{{text x-y-and-z}}
x-y-and-z = <p>Paragraph 1 contents.</p>
        <p>Paragraph 2 contents.</p>
        <p>Paragraph 3 contents.</p>

(re: tools/install.hbs)

@eignnx For now, keep the paragraphs in the translation file (i.e. use one variable)

@Manishearth now working on cli.ftl

@Manishearth now working on policy pages. There's a lot of content here, so I think I will break it up into 5 files:

  1. policies.ftl (corresponding to templates/policies/index.hbs)
  2. code-of-conduct.ftl
  3. licenses.ftl
  4. media-guide.ftl
  5. security.ftl

Sounds good!

On Fri, May 24, 2019, 4:28 PM Gideon Buckwalter notifications@github.com
wrote:

@Manishearth https://github.com/Manishearth now working on policy
pages. There's a lot of content here, so I think I will break it up into 5
files:

  1. policies.ftl (corresponding to templates/policies/index.hbs
    https://github.com/rust-lang/www.rust-lang.org/blob/i18n/templates/policies/index.hbs
    )
  2. code-of-conduct.ftl
  3. licenses.ftl
  4. media-guide.ftl
  5. security.ftl

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/rust-lang/www.rust-lang.org/issues/798?email_source=notifications&email_token=AAMK6SBHXY3ZACD5EO55DMTPXB2ZBA5CNFSM4HPIP7H2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWGYFII#issuecomment-495813281,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAMK6SF6WAJKW3DHN5PSA2LPXB2ZBANCNFSM4HPIP7HQ
.

@Manishearth I'm pulling these email addrs into core.ftl (based on this review) and it often requires two message-variables: one for the anchor tag in core.ftl, and one for the translation text that ought to be located in the original FTL file. This is kinda cumbersome.

What if we just keep the anchor tag and text in the original FTL file, and extract the href into core.ftl?

That doesn't apply in all cases, but if the link is like:

# index.ftl
thing = 
        Surrounding text <a href="ASDFASDFASDFASDFASDFASDFASDFASDFASDF">text to be translated</a> more text.

it makes more sense to just gonna extract the href to core.ftl as opposed to:

# index.ftl
thing =
        Surrounding text { -some-message } more text.
some-message-link-text = text to be translated
# core.ftl
-some-message =
        <a href="ASDFASDFASDFASDFASDFASDFASDFASDFASDF">{ some-message-link-text }</a>

Oh, no, that won't work with the fallback.

We can use textparam for this. For now just move the link wholesale into core.ftl, I'll deal with it later.

Wait, you don't need to do that.

# index.ftl
thing =   Surrounding text <a href="{-some-link}">text to be translated</a> more text.

Clarification: this isn't about {{baseurl}} needing to use #textparam

Wait, you don't need to do that.

# index.ftl
thing =   Surrounding text <a href="{-some-link}">text to be translated</a> more text.

Yep, that's what I'm suggesting in this case

Yeah, do that.

core.ftl should not reference anything outside of it (otherwise fallback won't work)

@Manishearth are you worried at all about giant merge conflicts when i18n merges into master? I'm looking at #780 PRs (like some of the class additions to h3 and img tags in #806) and it kinda looks like we might have a lot to do. Luckily, the Embedded page hasn't been i18n-ified yet; is there a way we can merge @skade 's CSS changes into i18n before localizing the Embedded page?

I'm periodically merging back and forth. All the current work (except maybe policies) has merged already.

Good catch! We can merge the PRs into our branch early, or we can start work on those last. I'll also start reviewing those.

I approved it, if you're going to start on embedded make sure to base your changes on that. I plan to merge after I get home (and I'll then sync with the i18n branch)

@Manishearth Now working on embedded.ftl

@Manishearth Now working on wasm.ftl

I might look at networking

@Manishearth I'm gonna do the 404 page real quick, I'll put it in 404.ftl

Alright, but let's not translate the 500 page.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

camelid picture camelid  Â·  4Comments

Diggsey picture Diggsey  Â·  6Comments

joboscribe picture joboscribe  Â·  6Comments

eignnx picture eignnx  Â·  3Comments

Aloso picture Aloso  Â·  4Comments