Locale-Utils-PlaceholderBabelFish

 view release on metacpan or  search on metacpan

javascript/Example.html  view on Meta::CPAN

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <style type="text/css"></style>
        <!-- depends on -->
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
        <script type="text/javascript" src="./Locale/Utils/PlaceholderBabelFish.js"></script>
    </head>
    <body>
        <h1>Version: 0.002</h1>
        <script type="text/javascript">
            localeUtilsPlaceholderBabelFish.prototype.pluralCode = function(count) {
                return count == 1 ? 0 : 1;
            };
            var babelFish = new localeUtilsPlaceholderBabelFish();

            var c = function(comment) {
                document.writeln('<h1>' + comment + '</h1>');
            };
            var b = function (text, expected) {
                document.writeln(
                    '<pre>'
                    + 'got:      ' + babelFish.expandBabelFish(text) + '\n'
                    + 'expected: ' + expected
                    + '</pre>'
                );
            };
            var bx = function (text, argMap, expected) {
                document.writeln(
                    '<pre>'
                    + 'got:      ' + babelFish.expandBabelFish(text, argMap) + '\n'
                    + 'expected: ' + expected
                    + '</pre>'
                );
            };

            c('text');
            b('simple string', 'simple string');
            b(
                'no placeholder \#{placeholder}', 
                'no placeholder #{placeholder}'
            );
            bx(
                'no plural \\((singular|plural))', 
                1,
                'no plural ((singular|plural))'
            );

            c('simple replace');
            bx(
                'single number argument #{count}', 
                1,
                'single number argument 1'
            );
            bx(
                'attribute num #{count :num}', 
                {'count' : 2},
                'attribute num 2'
            );
            bx(



( run in 1.334 second using v1.01-cache-2.11-cpan-119454b85a5 )