-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix readme and internationalize #12
base: master
Are you sure you want to change the base?
Changes from all commits
024846d
aae5688
e1be8fd
dba11a4
03f693c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"ep_headings.code" : "Code", | ||
"ep_headings.h1" : "Titel 1", | ||
"ep_headings.h2" : "Titel 2", | ||
"ep_headings.h3" : "Titel 3", | ||
"ep_headings.h4" : "Titel 4", | ||
"ep_headings.h5" : "Titel 5", | ||
"ep_headings.h6" : "Titel 6", | ||
"ep_headings.normal" : "Normal", | ||
"ep_headings.style" : "Stil", | ||
"ep_oae.download": "Download", | ||
"ep_oae.togglecolors": "Schaltet die Urheber Farben" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stuartf did you have a way in mind to sync this with crowdin? It would be preferential if the i18n keys could be part of the same project as 3akai-ux. I believe this could be done by adding a fourth location in 3akai-ux/tools/crowdin/crowdin.template that points to ep_oae's locales/en.json file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like those paths are relative to 3akai-ux though, and this source doesn't end up in there. |
||
"ep_headings.code": "Code", | ||
"ep_headings.normal": "Normal", | ||
"ep_headings.style": "Style", | ||
"ep_headings.h1": "Title 1", | ||
"ep_headings.h2": "Title 2", | ||
"ep_headings.h3": "Title 3", | ||
"ep_headings.h4": "Title 4", | ||
"ep_headings.h5": "Title 5", | ||
"ep_headings.h6": "Title 6", | ||
"ep_oae.download": "Download", | ||
"ep_oae.togglecolors": "Toggle authorship colors" | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/*! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My preference would be to align this key synchronisation script a lot more with the 3akai-ux synchronisation script. I don't have a strong opinion about whether we use the crowdin JAR file or the node library, but I do think we should pick one that was use in both places to avoid having to maintain 2 completely different approaches. The 3akai-ux synchronisation script also does some things (e.g. removing empty translation files) which this should be doing. @stuartf : What would be the best approach to aligning these more? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does remove the empty translation files. I think the 3akai-ux sync script might be simplified by using the npm crowdin module, but there are differences in how the two projects handle translations so they can't just use the same script. I.E. 3akai-ux uses properties files and needs the manifest files updated with a list of translations, ep_oae uses json files and they all just live in the locales directory. |
||
* Copyright 2013 Apereo Foundation (AF) Licensed under the | ||
* Educational Community License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
* http://www.osedu.org/licenses/ECL-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" | ||
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
var argv = require('optimist') | ||
.usage('Usage: $0 -a <crowdin API key>') | ||
|
||
.demand('a') | ||
.alias('a', 'apiKey') | ||
.describe('a', 'Crowdin API key') | ||
.argv; | ||
|
||
var _ = require('underscore'); | ||
var Crowdin = require('crowdin'); | ||
var fs = require('fs'); | ||
var temp = require('temp'); | ||
|
||
// Automatically track and cleanup files at exit | ||
temp.track(); | ||
|
||
var config = { | ||
endpointUrl: 'https://crowdin.com/api/project/apereo-oae' | ||
}; | ||
|
||
config.apiKey = argv.apiKey; | ||
|
||
var crowdin = new Crowdin(config); | ||
|
||
/** | ||
* Make a POST request to crowdin | ||
* | ||
* @param {String} path The path to the crowdin api endpoint | ||
* @param {Object} data The post data to be passed to request | ||
* @param {Function} callback A function to call on completion | ||
*/ | ||
var crowdinPost = function(path, data, callback) { | ||
data.key = config.apiKey; | ||
crowdin.requestData({ | ||
uri: config.endpointUrl + path, | ||
method: 'POST', | ||
formData: data, | ||
qs: { | ||
json: 'json' | ||
} | ||
}).then(callback); | ||
}; | ||
|
||
/** | ||
* Update the local translation files with data from crowdin | ||
*/ | ||
var downloadCrowdinTranslations = function() { | ||
console.log('Downloading translations'); | ||
temp.mkdir('crowdin', function(err, dirPath) { | ||
// Download all the OAE translations | ||
crowdin.downloadToPath(dirPath).then(function(){ | ||
// Copy the non-empty ep_oae bundles | ||
fs.readdir(dirPath + '/locales', function(err, files) { | ||
_.each(files, function(file) { | ||
fs.readFile(dirPath + '/locales/' + file, function(err, data) { | ||
var translations = JSON.parse(data); | ||
var notEmpty = _.values(translations).some(function(translation){ | ||
return translation !== ''; | ||
}); | ||
if (notEmpty){ | ||
fs.createReadStream(dirPath + '/locales/' + file).pipe(fs.createWriteStream(__dirname + '/../locales/' + file)); | ||
} | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
// Upload keys | ||
var keysPostData = { | ||
'files[/ep_oae/locales/en.json]': fs.createReadStream(__dirname + '/../locales/en.json') | ||
}; | ||
console.log('Uploading keys'); | ||
crowdinPost('/update-file', keysPostData, function() { | ||
console.log('Uploading translations'); | ||
// Upload existing translations | ||
fs.readdir(__dirname + '/../locales', function(err, files) { | ||
// After all the translations are uploaded, download any changes | ||
var done = _.after(files.length, downloadCrowdinTranslations); | ||
|
||
_.each(files, function(file) { | ||
// We don't upload translations for the source language, that's covered by the key upload | ||
if (file !== 'en.json') { | ||
var translationPostData = { | ||
key: config.apiKey, | ||
'files[/ep_oae/locales/en.json]': fs.createReadStream(__dirname + '/../locales/' + file), | ||
language: file.substring(0, 2) | ||
}; | ||
crowdinPost('/upload-translation', translationPostData, done); | ||
} else { | ||
done(); | ||
} | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this no longer recommended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's now recommended to have a SESSIONKEY.txt file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I had it in the settings.json I got this deprecation warning: