Help me please, how i can translate text "Drop an image here" in upload pop-up for my language?(for example ru_RU)? Buttons upload, browse for an image - translated with such solution:
tinymce.i18n.data.uk_UA['Upload'] = 'My text';
But "Drop an image here" can't(
this text from tinymce.js
define(
'tinymce.core.ui.DropZone',
[
'tinymce.core.ui.Widget',
'tinymce.core.util.Tools',
'tinymce.core.ui.DomUtils',
'global!RegExp'
],
function (Widget, Tools, DomUtils, RegExp) {
return Widget.extend({
/**
* Constructs a instance with the specified settings.
*
* #constructor
* #param {Object} settings Name/value object with settings.
* #setting {Boolean} multiple True if the dropzone is a multiple control.
* #setting {Number} maxLength Max length for the dropzone.
* #setting {Number} size Size of the dropzone in characters.
*/
init: function (settings) {
var self = this;
settings = Tools.extend({
height: 100,
text: "Drop an image here",
multiple: false,
accept: null // by default accept any files
}, settings);
self._super(settings);
self.classes.add('dropzone');
if (settings.multiple) {
self.classes.add('multiple');
}
},
To translate the text you need to modify the language file for the language(s) you wish to modify. If I download the current language file for uk_UA I see these two strings on lines 55 and 57
You need to change the right side of these two string to whatever you want them to be in each language.
Note: When we add new features to TinyMCE it often takes the community some time to translate the new strings in all the languages we support. We always welcome assistance with the translation process: https://www.transifex.com/moxiecode/tinymce/
if you did write and you want to translate it using some library you can use these i think it will help unless like the previous response check the controle constructor
https://github.com/muaz-khan/Translator ||
https://www.npmjs.com/package/google-translate-api
Related
I have file object and I wish to grab the URL.
screenshot of file object on Chrome console
I tried to output the properties like below, but all are giving me "undefined" except type and date.
console.log("file: " + file.type);
console.dir(file.attachment.attributes);
console.dir(file.attachment.attributes.date);
console.dir(JSON.stringify(file.attachment.attributes.author));
console.dir(file.attachment.attributes.width);
Here's how the file type looks like as below.
screenshot of file type on Chrome console
Is there something wrong with how I try to read them?
My code is based on WordPress wp-plupload.js that comes with core WordPress. Yeah, I know I shouldn't edit the core codes but I was just experimenting.
UPDATE: Below is the code.
/**
* After a file is successfully uploaded, update its model.
*
* #param {plupload.Uploader} up Uploader instance.
* #param {plupload.File} file File that was uploaded.
* #param {Object} response Object with response properties.
*/
fileUploaded = function (up, file, response) {
var complete;
// Remove the "uploading" UI elements.
_.each(["file", "loaded", "size", "percent"], function (key) {
file.attachment.unset(key);
});
file.attachment.set(_.extend(response.data, { uploading: false }));
wp.media.model.Attachment.get(response.data.id, file.attachment);
complete = Uploader.queue.all(function (attachment) {
return !attachment.get("uploading");
});
if (complete) {
Uploader.queue.reset();
}
self.success(file.attachment);
};
UPDATE: I just realized the file is NOT a file object after all.
$isFile = file instanceof File;
console.log("File? " + $isFile);
I received a "File? false". It's not a blob too! But I still wonder why I can't read the object and get the URL.
Ok, I solved the problem this way. To get the file object, I need to call file.getNative() as stated here -> https://www.plupload.com/docs/v2/File
Thanks to all for your guidance, for without you I would be a lesser coder..
I'm trying to test out a transaction but composer keeps throwing the following error which I don't quite understand:
TypeError: Cannot read property 'parameters' of undefined
It appears to be something to do with the Parameters concept in the modelling file. I'm just trying to update the parameters concept in the original asset to the new one defined by the transaction:
transactionProcessing:
/**
* Create paramter transaction
* #param {org.spear.gtm.homenode.parameterUpdate} homeNodeTransaction
* #transaction
*/
async function parameterProcessor(homeNodeTransaction){
const oldParameters = homeNodeTransaction.asset.parameters;
const newParameters = homeNodeTransaction.newParameters;
homeNodeTransaction.asset.parameters = homeNodeTransaction.newParameters;
await getAssetRegistry('org.spear.gtm.homenode').then(registryResults.update(homeNodeTransaction.asset));
let event = getFactory().newEvent('org.spear.gtm.homenode', 'parameterUpdated');
event.updatedParameters = newParameters;
event.oldParameters = oldParameters;
emit(event);
}
participant
/*
* Licensed under the Apache 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.apache.org/licenses/LICENSE-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.
*/
/**
* The home node is acting as a participant
*/
namespace org.spear.gtm.homenode
import org.spear.gtm.devicenode.IoTDevice
/**
* Defining participants on the home network
*/
participant HomeNode identified by participantKey {
//Home node key
o String participantKey regex = /[A-Fa-f0-9]{64}/
//parameter concept acts as a parameter dictionary //'old value in transaction Processor'
o Parameters parameters
//reputation paramter
o Double reputation
//An array of devices belong to this home node
--> Devices[] devices
}
concept Parameters {
//Arbitary string representing JSON parameters
o String parameters default = 'off'
/**
More parameters to be added
o Double..
o Double..
o Integer..
*/
}
transaction parameterUpdate {
o Parameters newParameters //'new value in transaction processor'
}
transaction addDevice {
--> IoTDevice device
}
event parameterUpdated {
o Parameters oldParameters
o Parameters updatedParameters
}
event deviceAdded{
o String homeID
o String deviceID
}
I need to read data from a GPSMap 62 device using the device control Javascript library. Problem is, unlike older devices, this device stores its waypoints in separate .GPX files every day. The javascript library expects all tracks and waypoints to be in the current.gpx file, but the 62 stores them in e.g. Waypoints_06-MAY-14.gpx and so on each day.
Short of requiring users to manually upload the appropriate file, has anyone gotten the DeviceControl library to actually support the newer devices with separate GPX files?
As an added bonus, the Garmin Device Control library is deprecated, so no updates are forthcoming.
Some code
startReadFromGps: function(deviceNumber) {
this.plugin.StartReadFromGps( deviceNumber ); //invokes the external plugin
},
I've checked out plugin in version 2.3-RC1 (I do not know, which version do you use).
Indeed there is startReadFromGps method:
/** Initiates the read from the gps device conneted. Use finishReadFromGps and getGpsProgressXml to
* determine when the plugin is done with this operation. Also, use getGpsXml to extract the
* actual data from the device. <br/>
* <br/>
* Minimum plugin version 2.0.0.4
*
* #param deviceNumber {Number} assigned by the plugin, see getDevicesXml for
* assignment of that number.
* #see #finishReadFromGps
* #see #cancelReadFromGps
* #see #getDevicesXml
*/
startReadFromGps: function(deviceNumber) {
this.plugin.StartReadFromGps( deviceNumber );
},
So it uses getGpsXml. I assume that it uses specified filename that is read and method returns file's content. My first thought is to change the filename - it is possible with:
/** This the filename that wil contain the gps xml once the transfer is complete. Use with
* setWriteGpsXml to set what the file contents will be. Also, use startWriteToGps to
* actually make the write happen.
*
* #private
* #param filename {String} the actual filename that will end up on the device. Should only be the
* name and not the extension. The plugin will append the extension portion to the file name--typically .gpx.
* #see #setWriteGpsXml, #startWriteToGps, #startWriteFitnessData
*/
_setWriteFilename: function(filename) {
this.plugin.FileName = filename;
},
But _setWriteFilename is private method. However called by
startWriteToGps: function(gpsXml, filename, deviceNumber)
and
startWriteFitnessData: function(tcdXml, deviceNumber, filename, dataTypeName)
Since now I will check if calling those methods with your specified filename will override filename value permanently and further calling of startReadFromGps will use new filename.
I cannot test it, I didn't use this library but you can give a shot.
With relation to Exception "The disk is full " is thrown when trying to store data in usedata object in IE7+ which has been left unanswered:
I am heavily browsing a government website created with Oracle ADF using WatiN.
The website is located in a WPF window --> WindowsFormsHost --> WebBrowser control.
The website makes heavy use of this: http://msdn.microsoft.com/en-us/library/ie/ms531424(v=vs.85).aspx, via the save and load methods.
After 2-3 minutes of browsing, I get the following javascript error during one of the "save" calls:
The disk is full, character #, line ####.
When I get this error, the WebBrowser control is rendered completely useless (no further javascript commands can be executed) and my app must be restarted.
I have tried to clear browser cache, change it's location, clear localStorage, everything to no avail.
The PC that reproduces the error has IE10 installed, but via the registry I force IE8 / IE9 mode in the webbrowser control.
Is there any way to get around this problem?
Information on this is very scarce, so any help will be greatly appreciated.
I'm on linux, so no way to test this now, but the files in question are not stored in browser cache, but in
Note: As of IE 10 this no longer holds water. Ref. edit 2 below.
W7+: %HOMEPATH%\AppData\Roaming\Microsoft\Internet Explorer\UserData
# c:\users\*user-name*\...
XP : %HOMEPATH%\Application Data\Microsoft\Internet Explorer\UserData
# c:\Documents and Settings\*user-name*\...
Or, I guess, this one also work (as a short-cut), :
%APPDATA%\Roaming\Microsoft\Internet Explorer\UserData
Modify or delete the files there.
Note that the files are tagged as protected operating system files, so to view in Explorer you have to change view to include these. If you use cmd, as in Command Prompt you have to include the /a flag as in:
dir /a
Edit 1:
Note, that index.dat is the one holding information about allocated size etc. so it won't (probably) help to only delete/move the xml files.
Edit 2:
OK. Had a look at this in Windows 7 running IE 10.
In IE 7 (on XP) the above mentioned path have an index.dat file that gets updated on save by userData. The file holds various information such as size of the index file, number of sub folders, size of all files. Then an entry for each file with a number identifying folder, url where it was saved from, name of xml file, dates etc. Wrote a simple VBScript parser for this, but as IE 10 does not use the index.dat file it is a waste.
Under IE 10 there is no longer various index.dat files but a central database file in:
%APPDATA%\Local\Microsoft\Windows\WebCache\
On my system the database file is named WebCacheV01.dat, the V part seems to differ between systems and is perhaps an in-house version number rather then a file type version.
The files are tightly locked, and as such, if one want to poke at them one solution is to make a shadow copy by using tools such as vscsc, Shadowcopy etc.
Anyhow, hacking WebCacheVxx.dat would need a lot more work, so no attempts on that on my part (for now at least).
But, register that the file gets an entry with path to the old location – so e.g. on write of someElement.save("someStorageName");, WebCacheVxx.dat gets an entry like:
...\AppData\Roaming\Microsoft\Internet Explorer\UserData\DDFFGGHH\someStorageName[1].xml
and a corresponding file is created in the above path.
The local container.dat, however, is not updated.
userData
As for the issue at hand, clearing localStorage will not help, as userData is not part of that API.
Can not find a good example on how to clear userData. Though, one way is to use the console.
Example from testing on this page:
Save some text.
Hit F12 and enter the following to clear the data:
/* ud as an acronym for userData */
var i, at,
ud_name = "oXMLBranch",
ud_id = "oPersistText",
ud = document.getElementById(ud_id);
/* To modify the storage one have to ensure it is loaded. */
ud.load(ud_name);
/* After load, ud should have a xmlDocument where first child should hold
* the attributes for the storage. Attributes as in named entries.
*
* Example: ud.setAttribute("someText", "Some text");
* ud.save(ud_name);
*
* XML-document now has attribute "someText" with value "Some text".
*/
at = ud.xmlDocument.firstChild.attributes;
/* Loop attributes and remove each one from userData. */
for (i = 0; i < at.length; ++i)
ud.removeAttribute(at[i].nodeName);
/* Finally update the file by saving the storage. */
ud.save(ud_name);
Or as a one-liner:
var ud_name = "oXMLBranch", ud_id = "oPersistText", i, at, ud = document.getElementById(ud_id); ud.load(ud_name); at = ud.xmlDocument.firstChild.attributes; for (i = 0; i < at.length; ++i) ud.removeAttribute(at[i].nodeName); ud.save(ud_name);
Eliminating one restriction
There are some issues with this. We can eliminate at least one, by ignoring the ud_id and instead create a new DOM object:
var i, at,
ud_name = "oXMLBranch",
ud = document.createElement('INPUT');
/* Needed to extend properties of input to include userData to userdata. */
ud.style.behavior = 'url(#default#userdata)';
/* Needed to not get access denied. */
document.body.appendChild(ud);
ud.load(ud_name);
at = ud.xmlDocument.firstChild.attributes;
for (i = 0; i < at.length; ++i)
ud.removeAttribute(at[i].nodeName);
/* Save, or nothing is changed on disk. */
ud.save(ud_name);
/* Clean up the DOM tree */
ud.parentNode.removeChild(ud);
So by this one should be able to clear userData by knowing name of the storage, which should be same as the file name (excluding [1].xml) or by looking at the page source.
More issues
Testing on the page mentioned above I reach a disk is full limit at 65,506 bytes.
Your problem is likely not that the disk is full, but that a write attempt is done where input data is above limit. You could try to clear the data as mentioned above and see if it continues, else you would need to clear the data about to be written.
Then again this would most likely break the application in question.
In other words, error text should have been something like:
Write of NNN bytes is above limit of NNN and not disk is full.
Tested by attaching to window onerror but unfortunately source of error was not found:
var x1, x2, x3, x4 ;
window.onerror = function () {
x1 = window.event;
x2 = x1.fromElement; // Yield null
x3 = x1.srcElement; // Yield null
x4 = x1.type;
};
End note
Unless the clear userData method solves the issue, I do not know where to go next. Have not found any option to increase the limit by registry or other means.
But perhaps it get you a little further.
There might be someone over at Super User that is able to help.
I'm using javascript library jsPDF to create PDFs and I'd like to add a font to use it as text. This is how to call the function:
var doc = new jsPDF();
doc.addFont(PostScriptName, fontName, fontStyle, encoding);
And here is the info from the library:
#property id {String} PDF-document-instance-specific label assinged to the font.
#property PostScriptName {String} PDF specification full name for the font
#property encoding {Object} Encoding_name-to-Font_metrics_object mapping.
#name FontObject
What is PostScriptName and where to find it? I was looking for some information but can't find anything good.
How can I use this function?
What i already tried was this:
var doc = new jsPDF();
doc.addFont("Arial", "Arial", "Regular","Ansi");
And i get and error:
TypeError: Object #
EDIT:
ok, what I also find out that encoding must be type object. Does anyone know what kind of object should i put there?
I have been looking at this library myself recently and I don't think the addFont method is publicly exposed.
If you open the source code in the jsPDF.js file and look at the addFonts() method it shows exactly how this method is called internally though.
addFont('Helvetica-Bold', 'helvetica', 'bold', 'StandardEncoding');
Add this under Public API in jsPDF.js to expose the private addFont method:
API.addFont = function(postScriptName, fontName, fontStyle) {
addFont(postScriptName, fontName, fontStyle, 'StandardEncoding');
}
Now in your script you can set it like this:
//Add custom font
doc.addFont('arial', 'arial', 'normal');
doc.setFont("arial");