Эх сурвалжийг харах

[beeswax] Fix some missed strings during i18n

Romain Rigaux 13 жил өмнө
parent
commit
bea9e92

+ 4 - 4
apps/beeswax/src/beeswax/create_table.py

@@ -80,13 +80,13 @@ def create_table(request):
 
 IMPORT_PEEK_SIZE = 8192
 IMPORT_PEEK_NLINES = 10
-DELIMITERS = [ hive_val for hive_val, _, _ in beeswax.common.TERMINATORS ]
+DELIMITERS = [ hive_val for hive_val, desc, ascii in beeswax.common.TERMINATORS ]
 DELIMITER_READABLE = {'\\001' : 'ctrl-As',
                       '\\002' : 'ctrl-Bs',
                       '\\003' : 'ctrl-Cs',
-                      '\\t'   : 'tabs',
-                      ','     : 'commas',
-                      ' '     : 'spaces'}
+                      '\\t'   : _('tabs'),
+                      ','     : _('commas'),
+                      ' '     : _('spaces')}
 FILE_READERS = [ ]
 
 def import_wizard(request):

+ 26 - 27
apps/beeswax/src/beeswax/forms.py

@@ -15,18 +15,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from django import forms
+from django.utils.translation import ugettext as _, ugettext_lazy as _t
+
 import hive_metastore
 
-from django import forms
 from desktop.lib.django_forms import simple_formset_factory, DependencyAwareForm
 from desktop.lib.django_forms import ChoiceOrOtherField, MultiForm, SubmitButton
 from beeswax import common
 from beeswax import db_utils
 from beeswax import models
+from filebrowser.forms import PathField
 
-import filebrowser.forms
-
-from django.utils.translation import ugettext as _t
 
 def query_form():
   """Generates a multi form object for queries."""
@@ -51,9 +51,9 @@ class SaveForm(forms.Form):
   def __init__(self, *args, **kwargs):
     forms.Form.__init__(self, *args, **kwargs)
     self.fields['save'].label = _t('Save')
-    self.fields['save'].widget.label = _t('Save')
+    self.fields['save'].widget.label = _('Save')
     self.fields['saveas'].label = _t('Save As')
-    self.fields['saveas'].widget.label = _t('Save As')
+    self.fields['saveas'].widget.label = _('Save As')
 
   def clean_name(self):
     name = self.cleaned_data.get('name', '').strip()
@@ -66,7 +66,7 @@ class SaveForm(forms.Form):
     name = self.cleaned_data.get('name')
     if save and len(name) == 0:
       # Bother with name iff we're saving
-      raise forms.ValidationError(_t('Please enter a name'))
+      raise forms.ValidationError(_('Please enter a name'))
     return self.cleaned_data
 
   def set_data(self, name, desc=''):
@@ -80,7 +80,7 @@ class SaveForm(forms.Form):
 class SaveResultsForm(DependencyAwareForm):
   """Used for saving the query result data"""
 
-  SAVE_TYPES = (SAVE_TYPE_TBL, SAVE_TYPE_DIR) = (_t('to a new table'), _t('to HDFS directory'))
+  SAVE_TYPES = (SAVE_TYPE_TBL, SAVE_TYPE_DIR) = (_('to a new table'), _('to HDFS directory'))
   save_target = forms.ChoiceField(required=True,
                                   choices=common.to_choices(SAVE_TYPES),
                                   widget=forms.RadioSelect)
@@ -88,10 +88,9 @@ class SaveResultsForm(DependencyAwareForm):
                                   label=_t("Table Name"),
                                   required=False,
                                   help_text=_t("Name of the new table"))
-  target_dir = filebrowser.forms.PathField(
-                                  label=_t("Results Location"),
-                                  required=False,
-                                  help_text=_t("Empty directory in HDFS to put the results"))
+  target_dir = PathField(label=_t("Results Location"),
+                        required=False,
+                        help_text=_t("Empty directory in HDFS to put the results"))
   dependencies = [
     ('save_target', SAVE_TYPE_TBL, 'target_table'),
     ('save_target', SAVE_TYPE_DIR, 'target_dir'),
@@ -102,7 +101,7 @@ class SaveResultsForm(DependencyAwareForm):
     if tbl:
       try:
         db_utils.meta_client().get_table("default", tbl)
-        raise forms.ValidationError(_t('Table already exists'))
+        raise forms.ValidationError(_('Table already exists'))
       except hive_metastore.ttypes.NoSuchObjectException:
         pass
     return tbl
@@ -150,7 +149,7 @@ SettingFormSet = simple_formset_factory(SettingForm)
 
 
 # In theory, there are only 256 of these...
-TERMINATOR_CHOICES = [ (hive_val, desc) for hive_val, desc, _ in common.TERMINATORS ]
+TERMINATOR_CHOICES = [ (hive_val, desc) for hive_val, desc, ascii in common.TERMINATORS ]
 
 class CreateTableForm(DependencyAwareForm):
   """
@@ -169,11 +168,11 @@ class CreateTableForm(DependencyAwareForm):
 
   # Delimited Row
   # These initials are per LazySimpleSerDe.DefaultSeparators
-  field_terminator = ChoiceOrOtherField(required=False, initial=TERMINATOR_CHOICES[0][0],
+  field_terminator = ChoiceOrOtherField(label=_t("Field terminator"), required=False, initial=TERMINATOR_CHOICES[0][0],
     choices=TERMINATOR_CHOICES)
-  collection_terminator = ChoiceOrOtherField(required=False, initial=TERMINATOR_CHOICES[1][0],
+  collection_terminator = ChoiceOrOtherField(label=_t("Collection terminator"), required=False, initial=TERMINATOR_CHOICES[1][0],
     choices=TERMINATOR_CHOICES)
-  map_key_terminator = ChoiceOrOtherField(required=False, initial=TERMINATOR_CHOICES[2][0],
+  map_key_terminator = ChoiceOrOtherField(label=_t("Map key terminator"), required=False, initial=TERMINATOR_CHOICES[2][0],
     choices=TERMINATOR_CHOICES)
   dependencies += [
     ("row_format", "Delimited", "field_terminator"),
@@ -229,14 +228,14 @@ class CreateTableForm(DependencyAwareForm):
 def _clean_tablename(name):
   try:
     db_utils.meta_client().get_table("default", name)
-    raise forms.ValidationError(_t('Table "%(name)s" already exists') % {'name': name})
+    raise forms.ValidationError(_('Table "%(name)s" already exists') % {'name': name})
   except hive_metastore.ttypes.NoSuchObjectException:
     return name
 
 
 def _clean_terminator(val):
   if val is not None and len(val.decode('string_escape')) != 1:
-      raise forms.ValidationError(_t('Terminator must be exactly one character.'))
+      raise forms.ValidationError(_('Terminator must be exactly one character.'))
   return val
 
 
@@ -247,7 +246,7 @@ class CreateByImportFileForm(forms.Form):
   comment = forms.CharField(label=_t("Description"), required=False)
 
   # File info
-  path = filebrowser.forms.PathField(label=_t("Input File"))
+  path = PathField(label=_t("Input File"))
   do_import = forms.BooleanField(required=False, initial=True,
                           label=_t("Import data from file"),
                           help_text=_t("Automatically load this file into the table after creation."))
@@ -258,7 +257,7 @@ class CreateByImportFileForm(forms.Form):
 
 class CreateByImportDelimForm(forms.Form):
   """Form for step 2 (picking delimiter) of the import wizard"""
-  delimiter = ChoiceOrOtherField(required=False, initial=TERMINATOR_CHOICES[0][0],
+  delimiter = ChoiceOrOtherField(label=_t('Delimiter'), required=False, initial=TERMINATOR_CHOICES[0][0],
                                  choices=TERMINATOR_CHOICES)
   file_type = forms.CharField(widget=forms.HiddenInput, required=True)
 
@@ -266,7 +265,7 @@ class CreateByImportDelimForm(forms.Form):
     # ChoiceOrOtherField doesn't work with required=True
     delimiter = self.cleaned_data.get('delimiter')
     if not delimiter:
-      raise forms.ValidationError(_t('Delimiter value is required.'))
+      raise forms.ValidationError(_('Delimiter value is required.'))
     _clean_terminator(delimiter)
     return self.cleaned_data
 
@@ -276,10 +275,10 @@ class CreateByImportDelimForm(forms.Form):
         chr(int(delimiter))
         return int(delimiter)
       except ValueError:
-        raise forms.ValidationError(_t('Delimiter value must be smaller than 256.'))
+        raise forms.ValidationError(_('Delimiter value must be smaller than 256.'))
     val = delimiter.decode('string_escape')
     if len(val) != 1:
-      raise forms.ValidationError(_t('Delimiter must be exactly one character.'))
+      raise forms.ValidationError(_('Delimiter must be exactly one character.'))
     return ord(val)
 
 
@@ -303,8 +302,8 @@ class ColumnTypeForm(DependencyAwareForm):
     ("column_type", "map", "map_key_type"),
     ("column_type", "map", "map_value_type"),
   ]
-  column_name = common.HiveIdentifierField(required=True)
-  column_type = forms.ChoiceField(required=True,
+  column_name = common.HiveIdentifierField(label=_t('Column Name'), required=True)
+  column_type = forms.ChoiceField(label=_t('Column Type'), required=True,
     choices=common.to_choices(HIVE_TYPES))
   array_type = forms.ChoiceField(required=False,
     choices=common.to_choices(HIVE_PRIMITIVE_TYPES), label=_t("Array Value Type"))
@@ -322,7 +321,7 @@ PartitionTypeFormSet = simple_formset_factory(PartitionTypeForm, add_label=_t("a
 
 class LoadDataForm(forms.Form):
   """Form used for loading data into an existing table."""
-  path = filebrowser.forms.PathField(label=_t("Path"))
+  path = PathField(label=_t("Path"))
   overwrite = forms.BooleanField(required=False, initial=False,
     label=_t("Overwrite?"))
 

+ 2 - 2
apps/beeswax/src/beeswax/templates/beeswax_components.mako

@@ -17,12 +17,12 @@
   from desktop.lib.django_util import extract_field_data
   from django.utils.translation import ugettext as _
 %>
-<%def name="fieldName(field)">
 
+<%def name="fieldName(field)">
 </%def>
 
 <%def name="bootstrapLabel(field)">
-    <label for="${field.html_name | n}" class="control-label">${field.label | n}</label>
+    <label for="${field.html_name | n}" class="control-label">${field.label}</label>
 </%def>
 
 <%def name="label(

+ 1 - 4
apps/beeswax/src/beeswax/templates/choose_file.mako

@@ -47,10 +47,7 @@ ${layout.menubar(section='tables')}
                     <div class="control-group">
                         ${comps.bootstrapLabel(file_form["name"])}
                         <div class="controls">
-                            ${comps.field(file_form["name"],
-                            placeholder='table_name',
-                            show_errors=False
-                            )}
+                            ${comps.field(file_form["name"], placeholder=_('table_name'), show_errors=False)}
                             <span  class="help-inline">${unicode(file_form["name"].errors) | n}</span>
                         <span class="help-block">
                             ${_('Name of the new table. Table names must be globally unique. Table names tend to correspond as well to the directory where the data will be stored.')}

+ 7 - 4
apps/beeswax/src/beeswax/templates/create_table_manually.mako

@@ -45,6 +45,7 @@ ${layout.menubar(section='tables')}
 </ul>
 <form action="#" method="POST" id="mainForm" class="form-horizontal">
 <div class="steps">
+
 	<div id="step1" class="stepDetails">
 	    <fieldset>
 	        <div class="alert alert-info"><h3>${_('Create a table')}</h3>${_("Let's start with a name and description for where we'll store your data.")}</div>
@@ -52,8 +53,8 @@ ${layout.menubar(section='tables')}
 	            ${comps.bootstrapLabel(table_form["name"])}
 	            <div class="controls">
 	                ${comps.field(table_form["name"], attrs=dict(
-	                placeholder='table_name',
-	                )
+	                    placeholder=_('table_name'),
+	                  )
 	                )}
 	                <span  class="help-inline error-inline hide">This field is required. Spaces are not allowed.</span>
 	                <p class="help-block">
@@ -65,8 +66,8 @@ ${layout.menubar(section='tables')}
 	            ${comps.bootstrapLabel(table_form["comment"])}
 	            <div class="controls">
 	                ${comps.field(table_form["comment"], attrs=dict(
-	                placeholder=_('Optional'),
-	                )
+	                  placeholder=_('Optional'),
+	                  )
 	                )}
 	                <p class="help-block">
 	                    ${_("Use a table comment to describe your table.  For example, you might note the data's provenance and any caveats users need to know.")}
@@ -75,6 +76,7 @@ ${layout.menubar(section='tables')}
 	        </div>
 	    </fieldset>
 	</div>
+
 	<div id="step2" class="stepDetails hide">
 	    <fieldset>
 	        <div class="alert alert-info"><h3>${_('Choose Your Record Format')}</h3>
@@ -112,6 +114,7 @@ ${layout.menubar(section='tables')}
 	        </div>
 	    </fieldset>
 	</div>
+
 	<div id="step3" class="stepDetails hide">
 	    <fieldset>
 	        <div id="step3Delimited" class="stepDetailsInner">