Commit Graph

26 Commits

Author SHA1 Message Date
Ryan Shaw b5ae428dbf Make it so i18nliner understands `import(‘./foo’)`
Closes: CORE-1756

Test plan:
* write `import(‘foo/bar’).then(bar => {})` in a file in app/jsx
* run `bundle exec rake i18n:check`
* it should work
* make sure the other i18n rake tasks still work like
  `bundle exec rake i18n:generate_js`

Change-Id: I0966a5de4402232c57476249a3879b9ec1100992
Reviewed-on: https://gerrit.instructure.com/161632
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
2018-08-23 14:19:00 +00:00
Ryan Shaw e415eaa961 Use yarn workspaces
Run `script/nuke_node.sh` to clean everything up
Run `yarn install` it should install everything for everything
Run `yarn build` and `yarn test` they should work exactly as before

Change-Id: I11a27ff2d705c6cbb3b3f9029dd8b32138706146
Reviewed-on: https://gerrit.instructure.com/151356
Tested-by: Jenkins
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
2018-06-04 20:02:02 +00:00
Ryan Shaw bd9f3d21ff upgrade i18nliner-js to latest version
Test plan:
* i18n extraction/check should work still

Change-Id: I0056b0ca4fb725c68b9cf76bfddf37f9c151fe2b
Reviewed-on: https://gerrit.instructure.com/140504
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
2018-02-12 20:39:35 +00:00
Ryan Shaw 0d494b90cf Regenerate gems/canvas_18nliner/yarn.lock
Regenerating this file to use the newest versions
Available to stay up-to-date


Test plan:
`yarn install` should work & automated tests should pass

Change-Id: I6d0bb216fb139a5ce0712a2d849f065f071d71d6
Reviewed-on: https://gerrit.instructure.com/130129
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Tested-by: Jenkins
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
2017-11-01 19:02:20 +00:00
Brian Park 135e26df83 translate notes column at render time
closes: GRADE-25

Test Plan:
1. Navigate to gradezilla
2. Observe notes column is shown in current locale
3. Change locale and repeats step 1-2
4. Repeat steps 1-2 for OG, SRGB

Change-Id: I7cfc180c6676e7c626d570cef8cb0ec8f7fa08f5
Reviewed-on: https://gerrit.instructure.com/122808
Tested-by: Jenkins
Reviewed-by: Sheldon Leibole <sleibole@instructure.com>
Reviewed-by: Jeremy Neander <jneander@instructure.com>
QA-Review: Indira Pai <ipai@instructure.com>
Product-Review: Matt Goodwin <mattg@instructure.com>
2017-08-21 19:53:35 +00:00
Cody Cutrer 622ed3314a require yarn, not npm
Change-Id: I2dbb037d4cbb0de7952dde19196c6937d18924e9
Reviewed-on: https://gerrit.instructure.com/122554
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2017-08-14 15:27:14 +00:00
Landon Wilkins c5b5cc786d da licença part 53
add consistent license headers to all source files

Change-Id: I405d2def01ad68c76533b9254983497485cd7073
Reviewed-on: https://gerrit.instructure.com/110160
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-05-01 21:06:11 +00:00
Jon Jensen a2e90cb51b ensure canvas_i18nliner uses the right coffeescript
just use whatever canvas uses, so we get the new hotness. also stop using
old jasmine since it brings along coffeescript

also tweak gem_npm stuff so they can have legit devDependencies

Change-Id: I39e3c6b96903dbbc9c4c38a886431d9b6f292616
Reviewed-on: https://gerrit.instructure.com/106476
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-03-27 19:39:24 +00:00
Ryan Shaw db04f0b3c5 rename all .jsx files to .js
fixes: CNVS-34727

this will make webpack faster because it cuts down
the number of files it has to look for when
it looks a module up. right now, every time
someone asked for a app/jsx/whatever.jsx file
it had to do a stat for app/jsx/whatever.js first
and then look for app/jsx/whatever.jsx. it also
slows every lookup for handlebars/coffescript files
since it has to look for the jsx first

this was just the result of running this command:
find . -type f -name "*.jsx" | while read FNAME; do git mv "$FNAME" "${FNAME//.jsx/.js}"; done

test plan:
* automated specs should pass
* webpack build should run faster than the patchset
  before this one

Change-Id: Ia15ded6dc2b09c10c4f9070edcee9305b5b429ad
Reviewed-on: https://gerrit.instructure.com/101005
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
2017-03-16 20:22:15 +00:00
Jon Jensen 2b6fd97c83 fix i18nliner plugin jsx issue
also don't rely on plugin symlinks, as they are going away

test plan:
* be on canvas master
* have canvas analytics installed
* remove all compiled js in canvas and plugins
* run `rake i18n:generate` and save en.yml
* run `rake i18n:generate_js` and save the translations
* check out this commit
* run `rake i18n:generate` again and diff it:
  * confirm you get its missing jsx strings
  * confirm nothing else has changed
* run `rake i18n:generate_js` and diff the directory:
  * confirm public/javascripts/translations/analytics.js has all the
    missing strings
  * confirm no other translation files have changed

Change-Id: I274aecba899367b8a26bc6f8791adbddd1cec06b
Reviewed-on: https://gerrit.instructure.com/103683
Tested-by: Jenkins
Reviewed-by: Landon Wilkins <lwilkins@instructure.com>
Product-Review: Landon Wilkins <lwilkins@instructure.com>
QA-Review: Landon Wilkins <lwilkins@instructure.com>
2017-03-02 03:41:52 +00:00
Ryan Shaw 05f55c1c30 Deprecate `npm` client. Use `yarn` instead
Closes: CNVS-35152

This changes all our tooling that used `npm` to
Run scripts to use `yarn`. `npm` will still work
for now but if you have yarn installed, it will use
that.

Cheat Sheet:
old command      -> new command
npm install      -> yarn install (or just `yarn`)
npm run webpack  -> yarn run webpack
npm test         -> yarn test
See more at https://yarnpkg.com

Test plan:
* all Jenkins builds should pass
* without yarn installed:
* run script/nuke_node.sh
* it should work and warn you about how `npm` is deprecated
* now install yarn, e.g.: `brew install yarn`
* run script/nuke_node.sh again
* it should work and you should see silly yarn emoji
  in the output and it should be a lot faster

* the docker changes I made should work and docker should
  build correctly and use yarn.

Change-Id: I4aa31eeae3ecc504634a7c72a1ea0d3396f445e3
Reviewed-on: https://gerrit.instructure.com/102969
Tested-by: Jenkins
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
2017-03-01 19:39:01 +00:00
Jon Jensen 1282dbb015 i18nliner: infer scope from import in addition to AMD, closes SD-2097
also speed it up a hair by skipping coffeescript on non-i18ny files

test plan:
* i18n stuff should all pass jenkins
* g/100536 should be happier

Change-Id: I4a2dd70065dc80e82b062a93c662fc10c1b3cabf
Reviewed-on: https://gerrit.instructure.com/103460
Reviewed-by: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
Product-Review: Jon Jensen <jon@instructure.com>
2017-03-01 00:13:29 +00:00
Jon Jensen 02d13b4e17 compile_assets improvements, refs SD-2097
speed up require_js and webpack builds. here's how:

* bump i18nliner
  * it uses babel
  * it is much faster
* tweak canvas_i18nliner to not need to precompile anything
* run i18n:generate_js without having to precompile anything
* webpack can avoid running js:generate altogether

test plan:
* tests pass
* i18n works as per usual under requirejs
* i18n works as per usual under webpack
* `rake i18n:generate`:
   * builds identical yml before/after
   * runs faster now
   * works even if you nuke compiled coffee/jsx
* `rake i18n:generate_js`:
   * builds identical translation files before/after
   * runs faster now
   * works even if you nuke compiled coffee/jsx

Change-Id: I2682e68ff87168d9f76e20deb93713aa9a50477a
Reviewed-on: https://gerrit.instructure.com/103285
Tested-by: Jenkins
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
2017-02-28 00:34:37 +00:00
Ryan Shaw 82ea83da5f [webpack] fix translation calls in handlebars files
Fixes: CNVS-34067

Test plan:
* with webpack turned on and in prod mode
* run RAILS_ENV=production bundle exec rake canvas:compile_assets
* pick a different language on your user settings page (e.g.maori)
* go to /calendar
* the “week, Month, Agenda” buttons and everything
  else on the page should be translated into your language
* go to other pages, e.g. /courses/x/assignments/new
* all of the strings on those pages should be translated too

(The broken behavior was that any strings that came from handlebars
Files would not be translated but ones coming from js, erb or 
Coffeescript were)

Change-Id: I9a4b76e857b6c809b663d18abd7196ca10ef8564
Reviewed-on: https://gerrit.instructure.com/102534
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2017-02-17 04:34:24 +00:00
Simon Williams e4d7de76e3 fix canvas_i18nliner issue, along with its tests
it broke in the node upgrade (though fortunately not a feature we use),
and the tests were silently failing

test plan:
n/a, specs

Change-Id: Ib746b91e7500a31d8a8fb210af5afe8018c1dda3
Reviewed-on: https://gerrit.instructure.com/92764
Reviewed-by: Simon Williams <simon@instructure.com>
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins
2016-10-13 20:44:32 +00:00
Ryan Shaw f02b43f574 upgrade to node 6
closes: CNVS-29725

this gets everything working on node 6.

As far as our build process goes, it cannot support
running on both node 6 at the same time as 0.12
since our i18nliner handlebars stuff uses jsdom and
one version of it only works on node <4 and the
next only works on 4+.

But the stuff in the production dependencies in
package.json, aka the stuff that runs on the job
servers (brandable_css), can work on both. we just
need to run npm rebuild on the job servers if the stuff
that was npm installed into ./node_modules was compiled
against a different version of node. that is done here:
https://gerrit.instructure.com/81254
that commit needs to be committed to caturday before
we commit and deploy this to beta

as far as managing node, there are 2 "official"
ways that will make you life easier, you can either
just use docker or use nvm (https://github.com/creationix/nvm)

if you use nvm and if you use ZSH:
Put this into your $HOME/.zshrc to call nvm use automatically
whenever you enter a directory that contains an
.nvmrc file with a string telling nvm which node to use:

  # place this after nvm initialization!
  autoload -U add-zsh-hook
  load-nvmrc() {
    if [[ -f .nvmrc && -r .nvmrc ]]; then
      nvm use
    elif [[ $(nvm version) != $(nvm version default)  ]]; then
      echo "Reverting to nvm default version"
      nvm use default
    fi
  }
  add-zsh-hook chpwd load-nvmrc
  load-nvmrc

but however you do it, as long as you have node 6.2
installed it should work

test plan:
* install nvm
* check this patchset out
* run bundle exec rake canvas:compile_assets
* it should work
* use theme editor to preview a change to a theme
* it should work

Change-Id: I1cc9faed361938afc713c4b921042386b956db70
Reviewed-on: https://gerrit.instructure.com/80839
Tested-by: Jenkins
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Benjamin Christian Nelson <bcnelson@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
2016-08-09 23:37:07 +00:00
Clay Diffrient 43e99efe83 Lock jsdom to version 0.8.10 for i18nliner-canvas
closes gh-870

Test Plan:
  - Remove node_modules and do a fresh npm install
  - Everything should work without a tough-cookie error

Change-Id: I0ac48acbe2709a902c630a0b473b4f925b48199b
Reviewed-on: https://gerrit.instructure.com/86049
Tested-by: Jenkins
Reviewed-by: Derek Bender <djbender@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
2016-07-25 16:19:43 +00:00
John Corrigan 17d44b8a03 require scoped_hbs_pre_processor in i18nLinerHandlebars.js
fixes CNVS-28474

From what I could tell, none of the hbs templates were being passed the
`scope` value as part of the helper method `options.hash`, and that's
because we were not using the preprocesses that
PreProcessor.processStatement override via
frontend_build/i18nLinerHandelbars.js.

test plan:
- Load canvas using the Webpack build.
- Go into Calendar.
- Click on a day in the month and a Edit Event modal should pop up.
- Observe that the `Date:` labem is present, whereas it used to say
  [object Object].

Change-Id: I8e077261379b43f5be27ab6544d9d05a47e97625
Reviewed-on: https://gerrit.instructure.com/81558
Reviewed-by: Ryan Shaw <ryan@instructure.com>
Tested-by: Jenkins
QA-Review: Pedro Fajardo <pfajardo@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
2016-06-09 22:11:20 +00:00
Cody Cutrer f552f4fc00 simplify gem test harnesses
rely on test_all_gems.sh to output header and trailer,
and use `set -e` in each test.sh to simplify passing
through errors

Change-Id: I3ba724ad2539ddfe31195394c43f646acfc73920
Reviewed-on: https://gerrit.instructure.com/70469
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2016-01-19 17:52:58 +00:00
Jon Jensen c449a8ba5c explicit jsdom and qunit dependencies for npm v3
since other projects have been known to upgrade npm on a jenkins node in
the course of a build, affecting subsequent canvas builds  ಠ_ಠ

test plan:
npm install should be happy on npm v3

Change-Id: I6767dac7dea7c8cfb4dfabbf94a29f6cccb00c15
Reviewed-on: https://gerrit.instructure.com/63708
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins
2015-09-21 22:27:02 +00:00
Ryan Shaw c9bac2d0ae add dep to i18nliner that it was using but wasn't in package.json
Change-Id: I961cdcf00322f4240c7a233ae013a088f29d7ebd
Reviewed-on: https://gerrit.instructure.com/54802
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins
2015-05-26 22:51:23 +00:00
Cody Cutrer 9242c3dce9 bump i18nliner
gets a bug fix for key inference collisions

Change-Id: I76dfedf7258050a79ebca918807aa6bde9a2ce89
Reviewed-on: https://gerrit.instructure.com/47813
Reviewed-by: Jon Jensen <jon@instructure.com>
Tested-by: Jenkins
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
2015-01-26 20:01:57 +00:00
Jon Jensen 1581b4cf91 fix js/hbs i18n key inference, fixes CNVS-18093
ensure inferred keys are never scoped to the file

this fixes the current broken behavior:

  {{#t}}...{{/t}}
    scoped at extraction time
    not scoped at runtime

  {{t ...}} and I18n.t
    not scoped at extraction time
    scoped at runtime

ruby key inference already works correctly (never scoped to the file)

notes:

running i18n:generate will now put all inferred keys at the root level.
since no js/hbs inferred keys were actually resolving to their
translations, this won't break any currently working translations and
will fix a lot of stuff...

the inline hbs t and I18n.t calls will start working immediately (since it
was just a runtime scoping issue), the #t calls will automatically sort
themselves out with a transifex round trip (since they were scoped
incorrectly at extraction time). there are over 300 over the former and
about a dozen of the latter.

test plan:
1. confirm missing strings listed on ticket now show up. a good example of
   this is the new course wizard; whereas before nothing was translated,
   now everything is (apart from a few new strings that haven't made the
   transifex round trip)
2. see all the new specs
3. also, try it out yourself. essentially:
   1. run `rake i18n:generate`
   2. find the string you want to verify, and put a corresponding value
      in the right place in es.yml (or wherever) if there isn't already
      one
   3. run `rake canvas:compile_assets`
   4. run canvas with `RAILS_LOAD_ALL_LOCALES=true USE_OPTIMIZED_JS=true`
   5. switch to es (or whatever) and verify the translation is displayed

Change-Id: I0574b90acbdc4f6fda9c814a3607a9002c9e6a00
Reviewed-on: https://gerrit.instructure.com/47626
Tested-by: Jenkins
Reviewed-by: Jennifer Stern <jstern@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
2015-01-22 22:34:01 +00:00
Jon Jensen 1300bf0352 i18nliner-handlebars (part II)
extraction and runtime for ember handlebars

test plan:
1. verify string extraction:
   1. `rake js:generate i18n:generate` before and after this commit
   2. confirm `config/locales/generated/en.yml` is identical, except the
      now you get a bunch of new ember strings
2. verify js translation file generation:
   1. `rake i18n:generate_js` before and after this commit
   2. confirm the files in public/javascripts/translations are identical,
      plus a whole bunch of new ones for ember
3. confirm you can now use i18nliner-y features:
   1. block helper with no key `{{#t}}hello world{{/t}}`
   2. inline helper with no key `{{t "hello world"}}`

Change-Id: I7bca8aeba462e68f27973fa801e7f7dbc7b3c9ef
Reviewed-on: https://gerrit.instructure.com/43158
Reviewed-by: Jennifer Stern <jstern@instructure.com>
Product-Review: Jennifer Stern <jstern@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-10-30 06:25:50 +00:00
Jon Jensen 6d8bac05b4 i18nliner-handlebars (part I)
extraction and runtime for vanilla handlebars. ember will be part II
because its strings currently don't even get extracted on master
¯\_(ツ)_/¯

differences in generated yml:
1. `%h{...}` placeholders from hbs are just `%{...}`, since html-safety is
   inferred at runtime without needing a placeholder hint (6 occcurrences)
2. inline `{{t ...}}` calls are now extracted (6 occurrences)
3. some trivial whitespace difference around some wrappers (2 occurrences)
4. html-entities are correctly converted into unicode equivalents, e.g.
   `Move To&hellip;` -> `Move To…` (1 occurrence)

test plan:
1. verify string extraction:
   1. `rake js:generate i18n:generate` before and after this commit
   2. confirm `config/locales/generated/en.yml` is identical, except the
      differences listed above
2. verify js translation file generation:
   1. `rake i18n:generate_js` before and after this commit
   2. confirm the files in public/javascripts/translations are identical
3. verify hbs translation keys/scope behavior at runtime:
   1. run canvas w/ RAILS_LOAD_ALL_LOCALES=true and optimized js
   2. use canvas in spanish
   3. confirm that todo está bien
4. confirm you can now use i18nliner-y features:
   1. block helper with no key `{{#t}}hello world{{/t}}`
   2. inline helper with no key `{{t "hello world"}}`

Change-Id: Ic2a2c5cf102ca482919cbb91ac1c154467029685
Reviewed-on: https://gerrit.instructure.com/42942
Reviewed-by: Jennifer Stern <jstern@instructure.com>
Product-Review: Jennifer Stern <jstern@instructure.com>
QA-Review: Matt Fairbourn <mfairbourn@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-10-30 06:25:47 +00:00
Jon Jensen 8192132c3e i18nliner-js (part I)
this swaps out our "parsing" with i18nliner-js

also remove localization abilities of I18n.beforeLabel, since it's not
worth the trouble to support. it can still be called to format a string.

notable changes/fixes in generated yml:
1. client_apps are picked up by i18n:rake so they'll get translated...
   due to the old short-circuiting logic (`rc = rc && ...`), it would
   stop processing scripts within a particular file after the first one
   it found without an I18n.t
2. we no longer incorrectly double-escape special chars in our js strings
   (e.g. newlines are actually newlines, not a literal "\n")

test plan:
1. verify string extraction:
   1. `rake js:generate i18n:generate` before and after this commit
   2. confirm `config/locales/generated/en.yml` is identical, except the
      notable changes/fixes listed above
2. verify js translation file generation:
   1. `rake i18n:generate_js` before and after this commit
   2. confirm the files in public/javascripts/translations are identical
3. verify client_app checker still works:
   1. `cd client_apps/canvas_quiz_statistics/`
   2. `grunt check_i18n`

Change-Id: Ic8ad058bee1c9476f42916f10b612c1c08863fe3
Reviewed-on: https://gerrit.instructure.com/42809
Reviewed-by: Michael Ziwisky <mziwisky@instructure.com>
Product-Review: Michael Ziwisky <mziwisky@instructure.com>
QA-Review: Michael Ziwisky <mziwisky@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2014-10-30 06:25:36 +00:00