Skip to content

Commit

Permalink
Add Month Translations to monthOptions helper
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronjudd committed Nov 27, 2016
1 parent 5825750 commit 1588b3e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
1 change: 0 additions & 1 deletion .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ kadira:flow-router-ssr
matb33:collection-hooks
meteorhacks:ssr
meteorhacks:subs-manager
momentjs:moment
ongoworks:security
raix:ui-dropped-event
risul:moment-timezone
Expand Down
26 changes: 20 additions & 6 deletions client/modules/core/helpers/templates.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import * as moment from "moment-timezone";
import "moment/min/locales.min.js";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { i18next } from "/client/api";
import { Reaction } from "../";
import * as Collections from "/lib/collections";
import * as Schemas from "/lib/collections/schemas";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import moment from "moment-timezone";
import { toCamelCase } from "/lib/api";


/*
*
* Reaction Spacebars helpers
Expand Down Expand Up @@ -51,20 +53,32 @@ if (Package.blaze) {
*/
Template.registerHelper("monthOptions", function () {
const label = i18next.t("app.monthOptions", "Choose month");
const localLocale = moment;
// adding cases where our lang w/o region
// isn't predefined in moment.
localLocale.defineLocale("zh", {
parentLocale: "zh-cn"
});

localLocale.locale(i18next.language);
const monthOptions = [{
value: "",
label: label
}];
const months = moment.months();

const months = localLocale.months();
// parse into autoform array
for (const index in months) {
if ({}.hasOwnProperty.call(months, index)) {
const month = months[index];
const mnum = parseInt(index, 10) + 1;
monthOptions.push({
value: parseInt(index, 10) + 1,
label: month
value: mnum,
label: `${mnum} | ${month}`
});
}
}

return monthOptions;
});

Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"dependencies": {
"@reactioncommerce/authorize-net": "^1.0.7",
"accounting-js": "^1.1.1",
"autoprefixer": "^6.5.1",
"autosize": "^3.0.17",
"autoprefixer": "^6.5.3",
"autosize": "^3.0.19",
"avalara-taxrates": "^1.0.1",
"babel-runtime": "^6.18.0",
"bcrypt": "^0.8.7",
Expand All @@ -49,10 +49,10 @@
"jquery": "^3.1.1",
"jquery-i18next": "^1.1.0",
"later": "^1.2.0",
"lodash": "^4.16.3",
"lodash": "^4.17.2",
"meteor-node-stubs": "^0.2.3",
"moment": "^2.15.1",
"moment-timezone": "^0.5.5",
"moment": "^2.17.0",
"moment-timezone": "^0.5.9",
"node-geocoder": "^3.15.0",
"nodemailer": "^2.6.4",
"nodemailer-wellknown": "^0.2.0",
Expand Down

0 comments on commit 1588b3e

Please sign in to comment.