Viene indicato here che Babel può estrarre messaggi gettext per file Python e Javascript.Estrazione di messaggi gettext Javascript utilizzando l'estrattore Babel CLI
Babel viene fornito con un paio di estrattori built: python (che estrae messaggio per file sorgenti Python), javascript, e ignorano (che estratti nulla).
L'estrattore da riga di comando è documentato here - ma senza esempi sull'utilizzo.
Anche nello same pointer precedente, c'è qualche menzione di un file di configurazione da utilizzare con l'estrazione, ma non molto ampliato.
Quando eseguo il comando di base per l'estrattore su una directory con file js, ottengo solo l'intestazione .PO generata ma nessun messaggio.
$ pybabel extract /path/to/js-dir
# Translations template for PROJECT.
# Copyright (C) 2012 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <[email protected]ESS>, 2012.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2012-04-22 19:39+1000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
$
Qui è un segmento di esempio da un file js Sto cercando di estrarre i messaggi di:
else if(data.status == "1"){
var follow_html = gettext('Follow');
object.attr("class", 'button follow');
object.html(follow_html);
var fav = getFavoriteNumber();
fav.removeClass("my-favorite-number");
if(data.count === 0){
data.count = '';
fav.text('');
}else{
var fmts = ngettext('%s follower', '%s followers', data.count);
fav.text(interpolate(fmts, [data.count]));
}
}
sarei grato se qualcuno può fornire opzioni CLI esatte e le impostazioni di configurazione per rendere l'estrazione lavoro, o un puntatore a tale.
Quali sono le funzioni gettext/ngettext che stai usando nel tuo js? Sono allo stesso stadio ora - ho babel che lavora per html e python ma non js – fastmultiplication
In realtà è un progetto OS (Askbot) - puoi controllare qui https://github.com/ASKBOT/askbot-devel –
I A proposito, ho trovato il mio problema: http://stackoverflow.com/questions/10647449/serving-i18n-js-using-babel-django-jinja2 – fastmultiplication