Skip to content

Commit

Permalink
First i18n approach
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jan 4, 2016
1 parent fc5ae31 commit 3a58eb5
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 5 deletions.
4 changes: 2 additions & 2 deletions assets/css/bloggy.css

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions assets/js/bloggy.en_ES.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions assets/js/src/i18n/en_ES.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
window.i18n =
'.modal-title': 'Una vez a la semana, recibe lo último.'
'.modal-body p': '<strong>Política de Privacidad:</strong> No spam ni publicidad. Desunscríbete en cualquier momento.'
'fieldEmail': 'Tu correo electrónico'
'.poweredby': ' © 2016. Todos los derechos reservados. Construido con <a href="https://github.com/Kikobeats/bloggy" target="_blank">Bloggy</a> bajo <a href="https://ghost.org/" target="_blank">Ghost</a>.'
'.modal-body .button-add.wide': 'Subscribirse'
'.subscribe-banner': '¿Te gustaría recibir el contenido en tu correo mensualmente? &nbsp;<a class="button" data-toggle="modal" data-target="#blogsubscribe">Subscríbete</a>',
'.read-more': 'Leer Más'
'.newer-posts': '← Publicaciones recientes'
'.older-posts': 'Publicaciones antiguas →'
'.page-number': 'Página % de $'
'a.post-meta': '← Volver a la Portada'
'.prefix-date': 'el'
'footer .button-add.large.wide': 'Subscríbete y recíbelo semalmente en tu correo'
'.read-next-story .post:before': 'Leer siguiente publicación'
39 changes: 39 additions & 0 deletions assets/js/src/i18n/index.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
$ ->
selectors = [
# newsletter modal
'.subscribe-banner'
'.modal-title'
'.modal-body p'
'.modal-body .button-add.wide'
# default view
'.read-more'
'.older-posts'
'.newer-posts'
'.poweredby'
# post view
'footer .button-add.large.wide'
'a.post-meta'
'.prefix-date'
]

for selector in selectors when i18n[selector]
$(selector).html(i18n[selector])

# inline css

css_selector = '.read-next-story .post:before'
property = "<style>.read-next-story .post:before{ content: '#{i18n[css_selector]}' }</style>"
$('head').append(property)

# pagination

selector = '.page-number'
pageNumber = $(selector).html().split(' ')
pageNumberi18n = i18n[selector].split(' ')
pageNumber[n] = pageNumberi18n[n] for n in [0, 2]
$(selector).html(pageNumber.join(' '))

# forms

selector = 'fieldEmail'
window[selector].placeholder = i18n[selector]
1 change: 0 additions & 1 deletion default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<div class="clearfix"></div>
{{> footer}}
{{ghost_foot}}
<script type="text/javascript" src="{{asset "js/bloggy.js"}}"></script>
{{> google-analytics}}
{{!> share/default}}
</body>
Expand Down
26 changes: 24 additions & 2 deletions gulpfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ src =
sass:
main : 'assets/scss/bloggy.scss'
files : ['assets/scss/**/**']

js :
i18n :
main : 'assets/js/src/i18n/index.coffee'
languages :
path: 'assets/js/src/i18n'
supported: ['en_ES']

main : [ 'assets/js/src/__init.coffee'
'assets/js/src/main.coffee' ]
vendor : ['assets/js/src/application.js'
Expand Down Expand Up @@ -67,12 +74,26 @@ gulp.task 'css', ->
.pipe gulp.dest dist.css
return

gulp.task 'js', ->
gulp.task 'js i18n', ->
src.js.i18n.languages.supported.forEach (lang) ->
gulp.src src.js.main
.pipe addsrc "#{src.js.i18n.languages.path}/index.coffee"
.pipe addsrc "#{src.js.i18n.languages.path}/#{lang}.coffee"
.pipe changed dist.js
.pipe coffee()
.pipe addsrc src.js.vendor
.pipe concat dist.name + ".#{lang}.js"
.pipe uglify mangle: false
.pipe header banner, pkg: pkg
.pipe gulp.dest dist.js
return

gulp.task 'js default', ->
gulp.src src.js.main
.pipe changed dist.js
.pipe coffee()
.pipe addsrc src.js.vendor
.pipe concat dist.name + '.js'
.pipe concat dist.name + ".js"
.pipe uglify mangle: false
.pipe header banner, pkg: pkg
.pipe gulp.dest dist.js
Expand All @@ -87,6 +108,7 @@ gulp.task 'server', ->
return

gulp.task 'build', ['css', 'js']
gulp.task 'js', ['js default', 'js i18n']

gulp.task "default", ->
gulp.start ["build", "server"]
Expand Down

0 comments on commit 3a58eb5

Please sign in to comment.