
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
flash-cognate
Advanced tools
Cognate is a set of translation tools for Flash/Animate CC
.xfl file format.fla file formatnpm install flash-cognate
`
## Usage
Generating translations files a Flash project:
```js
var cognate = require('flash-cognate'),
fs = require('fs');
// "segments" are a <div> and <span> representation of your text
var segments = cognate.getSegmentsForXflFileAtPath('~/Flash/project/main.xfl');
fs.writeFileSync('~/text/toBeTranslated.xml', segments.stringify());
Writing translations to a Flash project:
var cognate = require('flash-cognate'),
fs = require('fs');
var translated = fs.readFileSync('~/text/translated.xml');
var segments = cognate.parse(translated);
cognate.writeSegmentsToXflFileAtPath('~/Flash/project_german/main.xfl');
Cognate is essentially a wrapper around the fantastic Cheerio library, with various utility functions. Cognate has a load method which mirrors Cheerio's, but the result has some extended functionality that helps to manipulate Flash's symbol files.
Let's say that mySymbol.xml has these contents, in part:
...
<DOMStaticText>
<matrix>
<Matrix tx="2" ty="2"/>
</matrix>
<textRuns>
<DOMTextRun>
<characters>apple </characters>
<textAttrs>
<DOMTextAttrs face="Times" fillColor="#FFFFFF"/>
</textAttrs>
</DOMTextRun>
<DOMTextRun>
<characters>banana</characters>
<textAttrs>
<DOMTextAttrs face="Tahoma" fillColor="#FFE953"/>
</textAttrs>
</DOMTextRun>
</textRuns>
</DOMStaticText>
...
You can access them like so:
var cognate = require('flash-cognate'),
fs = require('fs');
var symbolFile = fs.readFileSync('~/Flash/project/LIBRARY/mySymbol.xml');
var $ = cognate.load(symbolFile);
var result = $('textRuns').withCharacters('apple banana').segment().stringify();
That would produce the output:
<div id="apple banana"><span style="font-family: Times; color: #FFFFFF;">apple </span><span style="font-family: Tahoma; color: #FFE953;">banana</span></div>
You can then modify the output and then save it back into your file:
...
result = result.replace('banana', 'mango');
var newSegment = cognate.parse(result);
$('textRuns').withCharacters('apple banana').segment(newSegment);
Every translator or translation system is different, so they're not all going to want <div> and <span> tags and so on. There are a number of different requirements for the format. To meet with this, the stringify() and parse() functions can be customized.
Here are Cognate's default ones:
stringify: function() {
return this.root().xml();
}
parse: function(xmlContent) {
var $ = exp.load(xmlContent); // exp is a reference to cognate
return $;
}
Here is an example of stringify/parse functions that enclose the <div> contents in a CDATA tag during translations:
var cognate = require('flash-cognate');
cognate.stringify = function() {
var $ = cognate.load('');
this.each(function(idx, elem){
var $elem = $(elem);
var cdata = '<![CDATA[' + $elem.xml() + ']]>';
$elem.html(cdata);
});
return this.root().xml();
}
cognate.parse = function(xmlContent) {
var $ = cognate.load(xmlContent);
$('div').each(function(idx, elem){
var $elem = $(elem);
var cdata = $elem.contents().filter(function(i, e){
return e.type === 'cdata';
});
$elem.html(cdata.text());
});
return $;
}
FAQs
Translation tools for Flash/Animate CC
We found that flash-cognate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.