-
Notifications
You must be signed in to change notification settings - Fork 298
Basic Fluent implementation #792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@renyuneyun the bugs were that the provider was still not static (and i don't think it was getting initialized properly) Furthermore, the directory needs to be present for this to work. One concern I have is that the code for replacing |
I think this would work better as a handlebars helper |
Alright, I've got a plan in place for supporting /paths |
Todo (mergeable without this):
|
An interesting case is when we have markup interspersed. The tagline is an example, currently I do A similar situation is the text: Whether you prefer working with code from the command line, or using
rich graphical editors, there’s a Rust integration available for your
editor of choice. Or you can build your own using the
<a href="https://github.com/rust-lang/rls">Rust Language Server</a>. I'm not sure what I should do with the link there. I have three options:
cc @zbraniecki |
Is there an active repo where translations are being done, or is that on hold until this feature is implemented? Besides the example with an anchor tag, what about the install page which uses JS to decide what path to show depending on detected OS?: <p>
In the Rust development environment, all tools are installed to the
<span class="platform-specific not-win di">
<code>~/.cargo/bin</code>
</span>
<span class="platform-specific win dn">
<code>%USERPROFILE%\.cargo\bin</code>
</span> directory,
and this is where you will find the Rust toolchain, including
<code>rustc</code>, <code>cargo</code>, and <code>rustup</code>.
</p> I'm not familiar with Fluent myself, but afaik it allows you to indicate where variables should be, in this case they don't really need a translation so the whole two span elements could be inserted as Technically for a translation, the translator should only need to be concerned about the identifier? None of your suggested approaches do that, is it something that can be done?
No need to have the open/close tags in the translation file? Seems to be pretty much what you said you do at the start before saying you only had 3 options. |
@polarathene The translation will be in this repository, hooked into a https://github.com/mozilla/pontoon instance once we got it set up. In JS, we can use the JS implementation of fluent. |
@polarthene the reason I can't do that is that I don't know how to nest Fluent calls in Handlebars. Maybe I should build a syntax for it. |
I guess writing a block helper would work! But that only gives me a single insertion point. Maybe |
Ah, so I think I can basically write something like {{#text rust-integration}}
{{#param rls}} <a href="https://github.com/rust-lang/rls"> {{text rust-language-server}} {{/param}}
{{/text}} may be tricky to pass down parameters (e.g. casing) though |
Ah, actually I was thinking of using this strategy (handlebars helper, though first time heard this name) initially, but couldn't find any document, and found the handlebars implementation seems to be a "internal" thing to Rocket. I'm not sure what the "bugs" your mean? I thought (for this case) whenever the compiler doesn't yield a lifetime problem, the life is correct (i.e. the declared lifetime is the same as the actual behaviour)? |
Does anyone have any clue why this github (online) diff shows everything of |
The code was broken and was reverted yesteday. I updated your code to the new edition, rebased, and squashed. |
No, the problem with the fairing was that it operated on substring replacement, which means that every time you replace an entry you're copying a significant part of the string. Handlebars works on a streaming basis (it doesn't construct the later parts of the string until it is done constructing the earlier parts of the string), it's designed for replacement and is much faster. Either way, the fairing wouldn't let us use more involved syntaxes: We need to be able to support So fairings are a good solution for a first pass (and i was fine with merging it that way), but for the final system we need to use handlebars. Since I'm building on your work here anyway, I thought I'd fix it. Your commit with the fairings support is still here (attributed to you) at the head of this PR.
So the directory and stuff wasn't pushed up, and I had weird edition errors because the branch was probably written before the edition upgrade (I didn't investigate, I just fixed it, this might have been a rebase problem). But also, like I'd done in my example branch you'd need to make both the list of bundles and the list of files in statics; the lifetime breaks down for more complex use cases. It wasn't a bug where it would fail to compile yet, it was one where further extensions would be broken. |
Interpolation in the latest commit, using |
d65c4c7
to
1928029
Compare
The "correct" solution is something like DOM Overlays , but I don't have time to implement that system in Rust. If someone wants to make a proper fluent handlebars crate, this might be what they should actually do. |
Added fallbacks, and baseurl. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found nothing except the leftover comments. The page works great locally.
.attach(Template::fairing()) | ||
.attach(templating) | ||
//.attach(I18N::dummy()) | ||
//.attach(I18N::from(Box::new(FluentI18nProvider::new(&fluent_collection)))) | ||
.attach(headers::InjectHeaders) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a couple of leftover comments.
Co-Authored-By: Florian Gilcher <florian.gilcher@asquera.de>
Moved over from #732 (reverted due to bugs)
Rebased and updated to work. Contains a single test string in use.