Clean up legal string interpolation

This commit is contained in:
Scott Erickson 2015-12-16 10:34:49 -08:00 committed by Rob
parent e9b59d62d6
commit e1130ff1e8
3 changed files with 9 additions and 14 deletions

View file

@ -1569,7 +1569,7 @@
email_settings_url: "your email settings"
email_description_suffix: "or through links in the emails we send, you can change your preferences and easily unsubscribe at any time."
cost_title: "Cost"
cost_description: "CodeCombat is free to play for all of its core levels, with a ${{price}} USD/mo subscription for access to extra level branches and {{gems}} bonus gems per month. You can cancel with a click, and we offer a 100% money-back guarantee."
cost_description_a: "CodeCombat is free to play for all of its core levels, with a ${{price}} USD/mo subscription for access to extra level branches and {{gems}} bonus gems per month. You can cancel with a click, and we offer a 100% money-back guarantee."
copyrights_title: "Copyrights and Licenses"
contributor_title: "Contributor License Agreement"
contributor_description_prefix: "All contributions, both on the site and on our GitHub repository, are subject to our"

View file

@ -52,7 +52,7 @@ block content
if !me.isOnPremiumServer()
h4(data-i18n="legal.cost_title")
| Cost
p#cost-description(data-i18n="legal.cost_description")
p#cost-description Loading...
h2(data-i18n="legal.copyrights_title")
| Copyrights and Licenses

View file

@ -10,17 +10,12 @@ module.exports = class LegalView extends RootView
@products = new Products()
@supermodel.loadCollection(@products, 'products')
onLoaded: ->
basicSub = @products.findWhere({name: 'basic_subscription'})
@price = (basicSub.get('amount') / 100).toFixed(2)
@gems = basicSub.get('gems')
super()
afterRender: ->
super()
# TODO: Figure out how to use i18n interpolation in this case
$el = @$('#cost-description')
f = =>
$el.text($el.text().replace('{{price}}', @price))
$el.text($el.text().replace('{{gems}}', @gems))
_.defer(f) # i18n call gets made immediately after render
basicSub = @products.findWhere({name: 'basic_subscription'})
return unless basicSub
text = $.i18n.t('legal.cost_description_a')
text = text.replace('{{price}}', (basicSub.get('amount') / 100).toFixed(2))
text = text.replace('{{gems}}', basicSub.get('gems'))
@$('#cost-description').text(text)