JavaScript library for translating the phonetic alphabet
Phony is a pure JavaScript library for translating messages to and from the NATO phonetic alphabet.
Its API
is extremely easy to use and exposes the simple translation functionality through
the global variable, phony
. The predefined phonetic alphabet is
based on the ITU
but Phony allows this to be easily extended
by adding and/or modifying characters.
The API
allows either a data
object or string message
to be
passed as the first argument. If a string is used all options will use their
default value; otherwise they can be set using the following properties;
"ITU"
alphabet is used by default
phony.to([data|message][, callback(error, result)])
Returns the phonetic alphabet representation of the message provided.
phony.from([data|message][, callback(error, result)])
Returns the human-readable version translated from the phonetic alphabet message provided.
The full potential of Phony can be accessed by customizing your interactions with the API via the exposed method which allows you to define (or redefine) supported characters.
phony.defineChar(character, translation[, callback(error)])
Maps a phonetic alphabet translation for a supported character (existing/new). When defining a character it's recommended (but not required) to specify its value using a Unicode escape sequence (codes can easily be found on Wikipedia) and follow these guidelines when specifying the translation;
Alfa
).
The Phony API exposes some properties and methods which may only be useful to users in special cases.
phony.noConflict([callback(error)])
Relinquish Phony's control of the phony
global variable. If another library uses this variable calling this method will
reassign it back to that library.
phony.ALPHABETS
The phonetic alphabet acronyms supported by Phony.
phony.VERSION
The current version of Phony.
If you have any problems with this library or would like to see the changes currently in development browse our issues.
Developers should run all tests (locally) and ensure they pass before submitting a pull request.
Take a look at the documentation to get a better understanding of what the code is doing.
If that doesn't help, feel free to follow me on Twitter, @neocotic.