Skip to content

Commit 03c6daa

Browse files
authored
Merge pull request #958 from Manishearth/rename-templates
Move templates closer to what handlebars-fluent uses
2 parents e770231 + 81c2e51 commit 03c6daa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+600
-586
lines changed

src/i18n.rs

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,20 @@ impl HelperDef for I18NHelper {
177177
id
178178
} else {
179179
return Err(RenderError::new(
180-
"{{text}} must have at least one parameter",
180+
"{{fluent}} must have at least one parameter",
181181
));
182182
};
183183

184-
let id = if let Some(id) = id.path() {
185-
id
184+
if id.path().is_some() {
185+
return Err(RenderError::new(
186+
"{{fluent}} takes a string parameter with no path",
187+
));
188+
}
189+
190+
let id = if let Json::String(ref s) = *id.value() {
191+
s
186192
} else {
187-
return Err(RenderError::new("{{text}} takes an identifier parameter"));
193+
return Err(RenderError::new("{{fluent}} takes a string parameter"));
188194
};
189195

190196
let mut args = if h.hash().is_empty() {
@@ -213,23 +219,31 @@ impl HelperDef for I18NHelper {
213219
let args = args.as_mut().unwrap();
214220
for element in &tpl.elements {
215221
if let TemplateElement::HelperBlock(ref block) = element {
216-
if block.name != "textparam" {
222+
if block.name != "fluentparam" {
217223
return Err(RenderError::new(format!(
218-
"{{{{text}}}} can only contain {{{{textparam}}}} elements, not {}",
224+
"{{{{fluent}}}} can only contain {{{{fluentparam}}}} elements, not {}",
219225
block.name
220226
)));
221227
}
228+
222229
let id = if let Some(el) = block.params.get(0) {
223-
if let Parameter::Name(ref s) = *el {
224-
s
230+
if let Parameter::Literal(ref s) = *el {
231+
if let Json::String(ref s) = *s {
232+
s
233+
} else {
234+
return Err(RenderError::new(
235+
"{{fluentparam}} takes a string parameter",
236+
));
237+
}
225238
} else {
226239
return Err(RenderError::new(
227-
"{{textparam}} takes an identifier parameter",
240+
"{{fluentparam}} takes a string parameter",
228241
));
229242
}
230243
} else {
231-
return Err(RenderError::new("{{textparam}} must have one parameter"));
244+
return Err(RenderError::new("{{fluentparam}} must have one parameter"));
232245
};
246+
233247
if let Some(ref tpl) = block.template {
234248
let mut s = StringOutput::default();
235249
tpl.render(reg, context, rcx, &mut s)?;

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ fn main() {
451451
let templating = Template::custom(|engine| {
452452
engine
453453
.handlebars
454-
.register_helper("text", Box::new(I18NHelper::new()));
454+
.register_helper("fluent", Box::new(I18NHelper::new()));
455455
engine
456456
.handlebars
457457
.register_helper("team-text", Box::new(TeamHelper::new()));

templates/404.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
44
<div class="flex-none flex-l mt5 mb5 tc tl-l">
55
<div class="w-70-l w-100">
6-
<h1>{{text error404-page-title}}</h1>
7-
<h2 class="subtitle">{{text error404-subtitle}}</h2>
6+
<h1>{{fluent "error"404-page-title}}</h1>
7+
<h2 class="subtitle">{{fluent "error"404-subtitle}}</h2>
88
</div>
99
<div class="w-30-l w-100 mt5 mt0-l">
10-
<img id="ferris-error" src="/static/images/ferris-error.png" alt="{{text error404-img-alt}}">
10+
<img id="ferris-error" src="/static/images/ferris-error.png" alt="{{fluent "error"404-img-alt}}">
1111
</div>
1212
</div>
1313
</div>

templates/community/index.hbs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<header class="mt3 mt2-ns mb4 mb5-ns tc tl-ns">
44
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
5-
<h1>{{text community-page-title}}</h1>
5+
<h1>{{fluent "community-page-title"}}</h1>
66
</div>
77
</header>
88

@@ -11,19 +11,19 @@
1111
<div class="flex flex-column flex-row-l">
1212
<div class="mw-50-l mh2-l pt0 flex flex-column justify-between-l">
1313
<p>
14-
{{text community-blurb}}
14+
{{fluent "community-blurb"}}
1515
</p>
1616
<p>
17-
{{text community-twir}}
17+
{{fluent "community-twir"}}
1818
</p>
19-
<a href="https://this-week-in-rust.org/" class="button button-secondary mb3">{{text community-twir-button}}</a>
19+
<a href="https://this-week-in-rust.org/" class="button button-secondary mb3">{{fluent "community-twir-button"}}</a>
2020
</div>
2121
<div class="mw-50-l mh2-l pt0 flex flex-column justify-between-l">
2222
<p>
23-
{{text community-team-contact}}
23+
{{fluent "community-team-contact"}}
2424
</p>
2525

26-
<a href="mailto:[email protected]" class="button button-secondary mb3">{{text community-team-button}}</a>
26+
<a href="mailto:[email protected]" class="button button-secondary mb3">{{fluent "community-team-button"}}</a>
2727
</div>
2828
</div>
2929

@@ -33,48 +33,48 @@
3333
<section id="contribute-talk" class="white">
3434
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
3535
<header>
36-
<h2>{{text community-where}}</h2>
36+
<h2>{{fluent "community-where"}}</h2>
3737
<div class="highlight"></div>
3838
</header>
3939
<div class="flex flex-column flex-row-l">
4040
<div class="mw-33-l mh3-l pt0 flex flex-column justify-start" id="users-forum">
4141
<div class="flex-grow-1">
42-
<h3 class="mt0 mb4">{{text community-urlo-header}}</h3>
42+
<h3 class="mt0 mb4">{{fluent "community-urlo-header"}}</h3>
4343
<p>
44-
{{text community-urlo}}
44+
{{fluent "community-urlo"}}
4545
</p>
4646
</div>
4747

48-
<a href="https://users.rust-lang.org" class="button button-secondary">{{text community-discourse-button}}</a>
48+
<a href="https://users.rust-lang.org" class="button button-secondary">{{fluent "community-discourse-button"}}</a>
4949
</div>
5050

5151
<div class="mw-33-l mh3-l pt4 pt0-l flex flex-column justify-start" id="internals-forum">
5252
<div class="flex-grow-1">
53-
<h3 class="mt0 mb4">{{text community-irlo-header}}</h3>
53+
<h3 class="mt0 mb4">{{fluent "community-irlo-header"}}</h3>
5454
<p>
55-
{{text community-irlo}}
55+
{{fluent "community-irlo"}}
5656
</p>
5757
</div>
5858

59-
<a href="https://internals.rust-lang.org" class="button button-secondary">{{text community-discourse-button}}</a>
59+
<a href="https://internals.rust-lang.org" class="button button-secondary">{{fluent "community-discourse-button"}}</a>
6060

6161
</div>
6262

6363
<div class="mw-33-l mh3-l pt4 pt0-l flex flex-column justify-start" id="chat-platforms">
6464
<div class="flex-grow-1">
65-
<h3 class="mt0 mb4">{{text community-chat-header}}</h3>
65+
<h3 class="mt0 mb4">{{fluent "community-chat-header"}}</h3>
6666
<p>
67-
{{text community-chat}}
67+
{{fluent "community-chat"}}
6868
</p>
6969
</div>
7070

7171
{{!-- TODO: remove padding and margin once global declarations are gone --}}
7272
<ul class="list pa0 ma0">
7373
<li class="mb3">
74-
<a href="https://discord.gg/rust-lang" class="button button-secondary">{{text discord}}</a>
74+
<a href="https://discord.gg/rust-lang" class="button button-secondary">{{fluent "discord"}}</a>
7575
</li>
7676
<li class="mb3">
77-
<a href="{{baseurl}}/governance" class="button button-secondary">{{text community-teams-learn}}</a>
77+
<a href="{{baseurl}}/governance" class="button button-secondary">{{fluent "community-teams-learn"}}</a>
7878
</li>
7979
</ul>
8080
</div>
@@ -85,57 +85,57 @@
8585
<section id="community-events" class="green">
8686
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
8787
<header>
88-
<h2>{{text community-events-header}}</h2>
88+
<h2>{{fluent "community-events-header"}}</h2>
8989
<div class="highlight"></div>
9090
</header>
9191
<div class="flex flex-column flex-row-l">
9292
<div class="mw-50-l mh3-l pt0 flex flex-column justify-between" id="meetups-usergroups">
9393
<div>
94-
<h3 class="mt0 mb4">{{text community-meetup-header}}</h3>
94+
<h3 class="mt0 mb4">{{fluent "community-meetup-header"}}</h3>
9595
<p>
96-
{{text community-meetup}}
96+
{{fluent "community-meetup"}}
9797
</p>
9898
</div>
9999
<ul class="list ma0 pa0">
100100
<li class="mb3">
101101
<a href="https://calendar.google.com/calendar/embed?showTitle=0&showPrint=0&showTabs=0&showCalendars=0&mode=AGENDA&height=400&wkst=1&bgcolor=%23FFFFFF&src=apd9vmbc22egenmtu5l6c5jbfc%40group.calendar.google.com&color=%23691426&ctz=Europe%2FMadrid"
102-
class="button button-secondary">{{text community-calendar}}</a>
102+
class="button button-secondary">{{fluent "community-calendar"}}</a>
103103
</li>
104104
<li class="mb3">
105105
<a href="https://blog.rust-lang.org/2019/05/20/The-2019-Rust-Event-Lineup.html"
106-
class="button button-secondary">{{text community-conference-lineup}}</a>
106+
class="button button-secondary">{{fluent "community-conference-lineup"}}</a>
107107
</li>
108108
<li class="mb3">
109109
<a href="https://timetill.rs"
110110
target="_blank"
111-
class="button button-secondary">{{text community-timetill-cta}}</a>
111+
class="button button-secondary">{{fluent "community-timetill-cta"}}</a>
112112
</li>
113113
</ul>
114114
</div>
115115
<div class="mw-50-l mh3-l pt4 pt0-l flex flex-column justify-between" id="conferences">
116116
<div>
117-
<h3 class="mt0 mb4">{{text community-event-run-header}}</h3>
118-
{{text community-event-run}}
117+
<h3 class="mt0 mb4">{{fluent "community-event-run-header"}}</h3>
118+
{{fluent "community-event-run"}}
119119
</div>
120120
<ul class="list ma0 pa0">
121121
<li class="mb3">
122-
<a href="https://github.com/rust-community/events-team#-rust-events-team" class="button button-secondary">{{text community-events-repo}}</a>
122+
<a href="https://github.com/rust-community/events-team#-rust-events-team" class="button button-secondary">{{fluent "community-events-repo"}}</a>
123123
</li>
124124
<li class="mb3">
125125
<a href="https://docs.google.com/forms/d/e/1FAIpQLSf52YXGhqBaHtCXtVna4iHYMK7IQaTqUW6V-ztsZC8C2TBInQ/viewform"
126-
class="button button-secondary">{{text community-event-register}}</a>
126+
class="button button-secondary">{{fluent "community-event-register"}}</a>
127127
</li>
128128
</ul>
129129
</div>
130130
</div>
131-
<img src="/static/images/rustfest.jpg" alt="{{text community-rustfest-alt}}">
131+
<img src="/static/images/rustfest.jpg" alt="{{fluent "community-rustfest-alt"}}">
132132
</div>
133133
</section>
134134

135135
<section id="rustbridge" class="white">
136136
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
137137
<header>
138-
<h2>{{text community-rustbridge-header}}</h2>
138+
<h2>{{fluent "community-rustbridge-header"}}</h2>
139139
<div class="highlight"></div>
140140
</header>
141141

@@ -145,35 +145,35 @@
145145
</div>
146146
<div class="mw-67-l mh3-l">
147147
<p>
148-
{{text community-rustbridge}}
148+
{{fluent "community-rustbridge"}}
149149
</p>
150-
<a href="https://github.com/rustbridge/team" class="button button-secondary">{{text community-rustbridge-button}}</a>
150+
<a href="https://github.com/rustbridge/team" class="button button-secondary">{{fluent "community-rustbridge-button"}}</a>
151151
</div>
152152
</div>
153153

154154
<ul class="list ma0 pa0 flex flex-column flex-row-ns flex-wrap-m flex-nowrap-l justify-center">
155-
<li class="tc max-width-half-m ph1-ns mb3"><img src="/static/images/rustbridge-rustconf.jpg" alt="{{text community-rustbridge-rustconf-alt}}" /></li>
156-
<li class="tc max-width-half-m ph1-ns mb3"><img src="/static/images/rustbridge-paris.jpg" alt="{{text community-rustbridge-paris-alt}}" /></li>
157-
<li class="tc max-width-half-m ph1-ns mb3"><img src="/static/images/rustbridge-berlin.jpg" alt="{{text community-rustbridge-berlin-alt}}" /></dv>
158-
<li class="tc max-width-half-m ph1-ns mb3"><img src="/static/images/rustbridge-rbr.jpg" alt="{{text community-rustbridge-rbr-alt}}" /></li>
155+
<li class="tc max-width-half-m ph1-ns mb3"><img src="/static/images/rustbridge-rustconf.jpg" alt="{{fluent "community-rustbridge-rustconf-alt"}}" /></li>
156+
<li class="tc max-width-half-m ph1-ns mb3"><img src="/static/images/rustbridge-paris.jpg" alt="{{fluent "community-rustbridge-paris-alt"}}" /></li>
157+
<li class="tc max-width-half-m ph1-ns mb3"><img src="/static/images/rustbridge-berlin.jpg" alt="{{fluent "community-rustbridge-berlin-alt"}}" /></dv>
158+
<li class="tc max-width-half-m ph1-ns mb3"><img src="/static/images/rustbridge-rbr.jpg" alt="{{fluent "community-rustbridge-rbr-alt"}}" /></li>
159159
</ul>
160160
</div>
161161
</section>
162162

163163
<section id="rustreach" class="red">
164164
<div class="w-100 mw-none ph3 mw8-m mw9-l center">
165165
<header>
166-
<h2>{{text community-irr-header}}</h2>
166+
<h2>{{fluent "community-irr-header"}}</h2>
167167
<div class="highlight"></div>
168168
</header>
169169
<div class="w-100 flex flex-column flex-row-l">
170170
<div class="mw-33-l mh3-l">
171171
<img src="/static/images/rustreach.jpg" alt="increasing rust's reach logo"/>
172172
</div>
173173
<div class="mw-67-l mh3-l">
174-
<p> {{text community-irr}}
174+
<p> {{fluent "community-irr"}}
175175
</p>
176-
<a href="http://reach.rust-lang.org/" class="button button-secondary">{{text community-irr-button}}</a>
176+
<a href="http://reach.rust-lang.org/" class="button button-secondary">{{fluent "community-irr-button"}}</a>
177177
</div>
178178
</div>
179179
</div>
@@ -182,21 +182,21 @@
182182
<section id="conduct" class="green">
183183
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
184184
<header>
185-
<h2>{{text community-standards-header}}</h2>
185+
<h2>{{fluent "community-standards-header"}}</h2>
186186
<div class="highlight"></div>
187187
</header>
188188
<div class="f3 f2-l">
189189
<p>
190-
{{#text community-standards}}
191-
{{#textparam url}}{{baseurl}}/policies/code-of-conduct{{/textparam}}
192-
{{/text}}
190+
{{#fluent "community-standards"}}
191+
{{#fluentparam "url"}}{{baseurl}}/policies/code-of-conduct{{/fluentparam}}
192+
{{/fluent}}
193193
</p>
194194
</div>
195195

196196
<div class="flex flex-column flex-row-l justify-between">
197-
<a href="mailto:[email protected]" class="button button-secondary mw-33-l mh3-l w-100 mb3">{{text community-mod-button}}</a>
198-
<a href="{{baseurl}}/policies/code-of-conduct" class="button button-secondary mw-33-l mh3-l w-100 mb3">{{text community-coc-button}}</a>
199-
<a href="{{baseurl}}/policies/code-of-conduct#moderation" class="button button-secondary mw-33-l mh3-l w-100 mb3">{{text community-mod-guidelines-button}}</a>
197+
<a href="mailto:[email protected]" class="button button-secondary mw-33-l mh3-l w-100 mb3">{{fluent "community-mod-button"}}</a>
198+
<a href="{{baseurl}}/policies/code-of-conduct" class="button button-secondary mw-33-l mh3-l w-100 mb3">{{fluent "community-coc-button"}}</a>
199+
<a href="{{baseurl}}/policies/code-of-conduct#moderation" class="button button-secondary mw-33-l mh3-l w-100 mb3">{{fluent "community-mod-guidelines-button"}}</a>
200200
</div>
201201
</div>
202202
</section>

templates/components/footer.hbs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,46 @@
22
<div class="w-100 mw-none ph3 mw8-m mw9-l center f3">
33
<div class="flex flex-column flex-row-ns pv0-l">
44
<div class="flex flex-column mw8 w-100 measure-wide-l pv2 pv5-m pv2-ns ph4-m ph4-l" id="get-help">
5-
<h4>{{text footer-get-help}}</h4>
5+
<h4>{{fluent "footer-get-help"}}</h4>
66
<ul>
7-
<li><a href="https://doc.rust-lang.org">{{text footer-doc}}</a></li>
8-
<li><a href="https://users.rust-lang.org">{{text footer-ask}}</a></li>
9-
<li><a href="http://ping.rust-lang.org">{{text footer-status}}</a></li>
7+
<li><a href="https://doc.rust-lang.org">{{fluent "footer-doc"}}</a></li>
8+
<li><a href="https://users.rust-lang.org">{{fluent "footer-ask"}}</a></li>
9+
<li><a href="http://ping.rust-lang.org">{{fluent "footer-status"}}</a></li>
1010
</ul>
1111
<div class="languages">
12-
<label for="language-footer" class="hidden">{{text choose-language}}</label>
12+
<label for="language-footer" class="hidden">{{fluent "choose-language"}}</label>
1313
<select id="language-footer">
1414
{{> components/languages-dropdown}}
1515
</select>
1616
</div>
1717
</div>
1818
<div class="flex flex-column mw8 w-100 measure-wide-l pv2 pv5-m pv2-ns ph4-m ph4-l">
19-
<h4>{{text footer-policies}}</h4>
19+
<h4>{{fluent "footer-policies"}}</h4>
2020
<ul>
21-
<li><a href="{{baseurl}}/policies/code-of-conduct">{{text footer-coc}}</a></li>
22-
<li><a href="{{baseurl}}/policies/licenses">{{text footer-licenses}}</a></li>
23-
<li><a href="{{baseurl}}/policies/media-guide">{{text footer-media}}</a></li>
24-
<li><a href="{{baseurl}}/policies/security">{{text footer-security}}</a></li>
25-
<li><a href="{{baseurl}}/policies/privacy">{{text policies-privacy-link}}</a></li>
26-
<li><a href="{{baseurl}}/policies">{{text footer-policies-all}}</a></li>
21+
<li><a href="{{baseurl}}/policies/code-of-conduct">{{fluent "footer-coc"}}</a></li>
22+
<li><a href="{{baseurl}}/policies/licenses">{{fluent "footer-licenses"}}</a></li>
23+
<li><a href="{{baseurl}}/policies/media-guide">{{fluent "footer-media"}}</a></li>
24+
<li><a href="{{baseurl}}/policies/security">{{fluent "footer-security"}}</a></li>
25+
<li><a href="{{baseurl}}/policies/privacy">{{fluent "policies-privacy-link"}}</a></li>
26+
<li><a href="{{baseurl}}/policies">{{fluent "footer-policies-all"}}</a></li>
2727
</ul>
2828
</div>
2929
<div class="flex flex-column mw8 w-100 measure-wide-l pv2 pv5-m pv2-ns ph4-m ph4-l">
30-
<h4>{{text footer-social}}</h4>
30+
<h4>{{fluent "footer-social"}}</h4>
3131
<div class="flex flex-row flex-wrap">
32-
<a href="https://twitter.com/rustlang"><img src="/static/images/twitter.svg" alt="twitter logo" title="{{text footer-youtube-alt}}"/></a>
33-
<a href="https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA"><img class="pv2" src="/static/images/youtube.svg" alt="{{text footer-alt-youtube}}" title="YouTube"/></a>
34-
<a href="https://discord.gg/rust-lang"><img src="/static/images/discord.svg" alt="discord logo" title="{{text footer-discord-alt}}"/></a>
35-
<a href="https://github.com/rust-lang"><img src="/static/images/github.svg" alt="github logo" title="{{text footer-github-alt}}"/></a>
32+
<a href="https://twitter.com/rustlang"><img src="/static/images/twitter.svg" alt="twitter logo" title="{{fluent "footer-youtube-alt"}}"/></a>
33+
<a href="https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA"><img class="pv2" src="/static/images/youtube.svg" alt="{{fluent "footer-alt-youtube"}}" title="YouTube"/></a>
34+
<a href="https://discord.gg/rust-lang"><img src="/static/images/discord.svg" alt="discord logo" title="{{fluent "footer-discord-alt"}}"/></a>
35+
<a href="https://github.com/rust-lang"><img src="/static/images/github.svg" alt="github logo" title="{{fluent "footer-github-alt"}}"/></a>
3636
</div>
3737
</div>
3838

3939
</div>
4040
<div class="attribution">
4141
<p>
42-
{{text footer-attribution}}
42+
{{fluent "footer-attribution"}}
4343
</p>
44-
<p>{{text footer-old-site}}</p>
44+
<p>{{fluent "footer-old-site"}}</p>
4545
</div>
4646
</div>
4747
</footer>

0 commit comments

Comments
 (0)