Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
c602b40b
Commit
c602b40b
authored
Apr 11, 2012
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More localizations work.
parent
313b826e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
358 additions
and
90 deletions
+358
-90
admin.pot
babel/admin.pot
+17
-1
babel.bat
babel/babel.bat
+1
-1
babel.sh
babel/babel.sh
+1
-1
simple.py
examples/babel/simple.py
+78
-0
babel.py
flask_adminex/babel.py
+13
-86
base.py
flask_adminex/base.py
+5
-1
__init__.py
flask_adminex/translations/__init__.py
+0
-0
admin.mo
flask_adminex/translations/ru/LC_MESSAGES/admin.mo
+0
-0
admin.po
flask_adminex/translations/ru/LC_MESSAGES/admin.po
+243
-0
No files found.
babel/admin.pot
View file @
c602b40b
...
@@ -9,7 +9,7 @@ msgid ""
...
@@ -9,7 +9,7 @@ msgid ""
msgstr ""
msgstr ""
"Project-Id-Version: Flask-AdminEx VERSION\n"
"Project-Id-Version: Flask-AdminEx VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2012-04-1
0 23:45
+0300\n"
"POT-Creation-Date: 2012-04-1
1 18:47
+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
...
@@ -18,6 +18,10 @@ msgstr ""
...
@@ -18,6 +18,10 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.6\n"
"Generated-By: Babel 0.9.6\n"
#: ../flask_adminex/base.py:216
msgid "Home"
msgstr ""
#: ../flask_adminex/form.py:81
#: ../flask_adminex/form.py:81
msgid "Invalid time format"
msgid "Invalid time format"
msgstr ""
msgstr ""
...
@@ -26,6 +30,10 @@ msgstr ""
...
@@ -26,6 +30,10 @@ msgstr ""
msgid "Invalid directory name"
msgid "Invalid directory name"
msgstr ""
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:40
msgid "File to upload"
msgstr ""
#: ../flask_adminex/ext/fileadmin.py:49
#: ../flask_adminex/ext/fileadmin.py:49
msgid "File required."
msgid "File required."
msgstr ""
msgstr ""
...
@@ -150,6 +158,14 @@ msgstr ""
...
@@ -150,6 +158,14 @@ msgstr ""
msgid "Model was successfully created."
msgid "Model was successfully created."
msgstr ""
msgstr ""
#: ../flask_adminex/model/filters.py:82
msgid "Yes"
msgstr ""
#: ../flask_adminex/model/filters.py:83
msgid "No"
msgstr ""
#: ../flask_adminex/templates/admin/lib.html:105
#: ../flask_adminex/templates/admin/lib.html:105
msgid "Submit"
msgid "Submit"
msgstr ""
msgstr ""
...
...
babel/babel.bat
View file @
c602b40b
pybabel extract -F babel.ini -k _gettext -k _ngettext -o admin.pot --project Flask-AdminEx ..\flask_adminex
pybabel extract -F babel.ini -k _gettext -k _ngettext -
k lazy_gettext -
o admin.pot --project Flask-AdminEx ..\flask_adminex
babel/babel.sh
View file @
c602b40b
#!/bin/sh
#!/bin/sh
pybabel extract
-F
babel.ini
-k
_gettext
-k
_ngettext
-o
admin.pot
--project
Flask-AdminEx ../flask_adminex
pybabel extract
-F
babel.ini
-k
_gettext
-k
_ngettext
-
k
lazy_gettext
-
o
admin.pot
--project
Flask-AdminEx ../flask_adminex
examples/babel/simple.py
0 → 100644
View file @
c602b40b
from
flask
import
Flask
,
request
,
session
from
flaskext.sqlalchemy
import
SQLAlchemy
from
flask.ext
import
adminex
,
wtf
from
flask.ext.babel
import
Babel
from
flask.ext.adminex.ext
import
sqlamodel
# Create application
app
=
Flask
(
__name__
)
# Create dummy secrey key so we can use sessions
app
.
config
[
'SECRET_KEY'
]
=
'12345678'
# Create in-memory database
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///test.sqlite'
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
db
=
SQLAlchemy
(
app
)
# Initialize babel
babel
=
Babel
(
app
)
@
babel
.
localeselector
def
get_locale
():
override
=
request
.
args
.
get
(
'lang'
)
if
override
:
session
[
'lang'
]
=
override
return
session
.
get
(
'lang'
,
'en'
)
# Create models
class
User
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
username
=
db
.
Column
(
db
.
String
(
80
),
unique
=
True
)
email
=
db
.
Column
(
db
.
String
(
120
),
unique
=
True
)
# Required for administrative interface
def
__unicode__
(
self
):
return
self
.
username
class
Post
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
title
=
db
.
Column
(
db
.
String
(
120
))
text
=
db
.
Column
(
db
.
Text
,
nullable
=
False
)
date
=
db
.
Column
(
db
.
DateTime
)
user_id
=
db
.
Column
(
db
.
Integer
(),
db
.
ForeignKey
(
User
.
id
))
user
=
db
.
relationship
(
User
,
backref
=
'posts'
)
def
__unicode__
(
self
):
return
self
.
title
# Flask views
@
app
.
route
(
'/'
)
def
index
():
return
'<a href="/admin/">Click me to get to Admin!</a>'
if
__name__
==
'__main__'
:
# Create admin
admin
=
adminex
.
Admin
(
app
,
'Simple Models'
)
admin
.
locale_selector
(
get_locale
)
# Add views
admin
.
add_view
(
sqlamodel
.
ModelView
(
User
,
db
.
session
))
admin
.
add_view
(
sqlamodel
.
ModelView
(
Post
,
db
.
session
))
# Create DB
db
.
create_all
()
# Start app
app
.
debug
=
True
app
.
run
(
'0.0.0.0'
,
8000
)
flask_adminex/babel.py
View file @
c602b40b
from
__future__
import
absolute_import
import
os.path
as
op
from
flask
import
_request_ctx_stack
try
:
try
:
from
babel
import
support
,
Locale
from
flask.ext.babel
import
Domain
from
speaklater
import
make_lazy_string
class
Namespace
(
object
):
def
__init__
(
self
,
dirname
=
None
,
namespace
=
''
,
default_locale
=
'en'
):
self
.
dirname
=
dirname
self
.
namespace
=
namespace
self
.
default_locale
=
Locale
.
parse
(
default_locale
)
def
_get_locale
(
self
):
ctx
=
_request_ctx_stack
.
top
if
ctx
is
None
:
return
None
locale
=
getattr
(
ctx
,
'admin_locale'
,
None
)
if
locale
is
None
:
admin
=
ctx
.
app
.
extensions
[
'admin'
]
if
admin
.
locale_selector_func
:
locale_name
=
admin
.
locale_selector_func
()
if
locale_name
:
locale
=
Locale
.
parse
(
locale_name
)
else
:
locale
=
self
.
default_locale
else
:
locale
=
self
.
default_locale
ctx
.
admin_locale
=
locale
return
locale
def
_get_translations
(
self
):
ctx
=
_request_ctx_stack
.
top
if
ctx
is
None
:
return
None
attr
=
'admin_trans_'
+
self
.
namespace
translations
=
getattr
(
ctx
,
attr
,
None
)
if
translations
is
None
:
dirname
=
self
.
dirname
or
op
.
join
(
ctx
.
app
.
root_path
,
'translations'
)
translations
=
support
.
Translations
.
load
(
dirname
,
[
self
.
_get_locale
()],
domain
=
self
.
namespace
)
setattr
(
ctx
,
attr
,
translations
)
return
translations
def
gettext
(
self
,
string
,
**
variables
):
translations
=
self
.
_get_translations
()
return
translations
.
ugettext
(
string
,
**
variables
)
def
ngettext
(
self
,
singular
,
plural
,
num
,
**
variables
):
translations
=
self
.
_get_translations
()
return
translations
.
ungettext
(
singular
,
plural
,
num
,
**
variables
)
def
lazy_gettext
(
self
,
string
,
**
variables
):
return
make_lazy_string
(
self
.
gettext
,
string
,
**
variables
)
except
ImportError
,
ex
:
class
DummyNamespace
(
object
):
def
__init__
(
self
,
dirname
=
None
,
namespace
=
'admin'
):
self
.
dirname
=
dirname
self
.
namespace
=
namespace
def
gettext
(
self
,
string
,
**
variables
):
return
string
%
variables
def
ngettext
(
self
,
singular
,
plural
,
num
,
**
variables
):
return
(
singular
if
num
==
1
else
plural
)
%
variables
def
lazy_gettext
(
self
,
string
,
**
variables
):
from
flask.ext.adminex
import
translations
return
string
%
variables
domain
=
Domain
(
translations
.
__path__
[
0
],
domain
=
'admin'
)
Namespace
=
DummyNamespace
gettext
=
domain
.
gettext
ngettext
=
domain
.
ngettext
lazy_gettext
=
domain
.
lazy_gettext
except
ImportError
:
def
gettext
(
string
,
**
variables
):
return
string
%
variables
# Create default namespace pointing to the flask-adminex localization directory
def
ngettext
(
singular
,
plural
,
num
,
**
variables
):
ns
=
Namespace
(
namespace
=
'admin'
)
return
(
singular
if
num
==
1
else
plural
)
%
variables
# Create shortcuts for default namespace
def
lazy_gettext
(
string
,
**
variables
):
gettext
=
ns
.
gettext
return
gettext
(
string
,
**
variables
)
ngettext
=
ns
.
ngettext
lazy_gettext
=
ns
.
lazy_gettext
flask_adminex/base.py
View file @
c602b40b
...
@@ -213,7 +213,11 @@ class AdminIndexView(BaseView):
...
@@ -213,7 +213,11 @@ class AdminIndexView(BaseView):
4. Automatically associates with static folder.
4. Automatically associates with static folder.
"""
"""
def
__init__
(
self
,
name
=
None
,
category
=
None
,
endpoint
=
None
,
url
=
None
):
def
__init__
(
self
,
name
=
None
,
category
=
None
,
endpoint
=
None
,
url
=
None
):
super
(
AdminIndexView
,
self
)
.
__init__
(
name
or
'Home'
,
category
,
endpoint
or
'admin'
,
url
or
'/admin'
,
'static'
)
super
(
AdminIndexView
,
self
)
.
__init__
(
name
or
babel
.
lazy_gettext
(
'Home'
),
category
,
endpoint
or
'admin'
,
url
or
'/admin'
,
'static'
)
@
expose
(
'/'
)
@
expose
(
'/'
)
def
index
(
self
):
def
index
(
self
):
...
...
flask_adminex/translations/__init__.py
0 → 100644
View file @
c602b40b
flask_adminex/translations/ru/LC_MESSAGES/admin.mo
0 → 100644
View file @
c602b40b
File added
flask_adminex/translations/ru/LC_MESSAGES/admin.po
0 → 100644
View file @
c602b40b
# Translations template for Flask-AdminEx.
# Copyright (C) 2012 ORGANIZATION
# This file is distributed under the same license as the Flask-AdminEx
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2012.
#
msgid ""
msgstr ""
"Project-Id-Version: Flask-AdminEx\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2012-04-11 18:47+0300\n"
"PO-Revision-Date: 2012-04-11 18:48+0200\n"
"Last-Translator: Serge S. Koval <serge.koval+github@gmail.com>\n"
"Language-Team: \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"
"X-Poedit-Language: Russian\n"
"X-Poedit-Country: RUSSIAN FEDERATION\n"
"X-Poedit-SourceCharset: utf-8\n"
#: ../flask_adminex/base.py:216
msgid "Home"
msgstr "Главная"
#: ../flask_adminex/form.py:81
msgid "Invalid time format"
msgstr "Неправильный формат времени."
#: ../flask_adminex/ext/fileadmin.py:32
msgid "Invalid directory name"
msgstr "Недопустимое имя директории"
#: ../flask_adminex/ext/fileadmin.py:40
msgid "File to upload"
msgstr "Файл"
#: ../flask_adminex/ext/fileadmin.py:49
msgid "File required."
msgstr "Необходимо выбрать файл"
#: ../flask_adminex/ext/fileadmin.py:54
msgid "Invalid file type."
msgstr "Недопустимый тип файла."
#: ../flask_adminex/ext/fileadmin.py:335
msgid "File uploading is disabled."
msgstr "Заливка файлов запрещена."
#: ../flask_adminex/ext/fileadmin.py:344
#, python-format
msgid "File \"%(name)s\" already exists."
msgstr "Файл с именем \"%(name)s\" уже существует."
#: ../flask_adminex/ext/fileadmin.py:351
#, python-format
msgid "Failed to save file: %(error)s"
msgstr "Ошибка сохранения файла: %(error)s"
#: ../flask_adminex/ext/fileadmin.py:370
msgid "Directory creation is disabled."
msgstr "Создание новых директорий запрещено."
#: ../flask_adminex/ext/fileadmin.py:380
#, python-format
msgid "Failed to create directory: %(error)s"
msgstr "Ошибка создания директории: %(error)s"
#: ../flask_adminex/ext/fileadmin.py:402
msgid "Deletion is disabled."
msgstr "Удаление запрещено."
#: ../flask_adminex/ext/fileadmin.py:407
msgid "Directory deletion is disabled."
msgstr "Удаление директорий запрещено."
#: ../flask_adminex/ext/fileadmin.py:412
#, python-format
msgid "Directory \"%s\" was successfully deleted."
msgstr "Директория \"%s\" была удалена."
#: ../flask_adminex/ext/fileadmin.py:414
#, python-format
msgid "Failed to delete directory: %(error)s"
msgstr "Ошибка удаления директории: %(error)s"
#: ../flask_adminex/ext/fileadmin.py:418
#, python-format
msgid "File \"%(name)s\" was successfully deleted."
msgstr "Файл \"%(name)s\" был удален."
#: ../flask_adminex/ext/fileadmin.py:420
#, python-format
msgid "Failed to delete file: %(name)s"
msgstr "Ошибка удаления файла: %(name)s"
#: ../flask_adminex/ext/fileadmin.py:439
msgid "Renaming is disabled."
msgstr "Переименование запрещено."
#: ../flask_adminex/ext/fileadmin.py:443
msgid "Path does not exist."
msgstr "Путь не существует."
#: ../flask_adminex/ext/fileadmin.py:454
#, python-format
msgid "Successfully renamed \"%(src)s\" to \"%(dst)s\""
msgstr "\"%(src)s\" был переименован в \"%(dst)s\""
#: ../flask_adminex/ext/fileadmin.py:457
#, python-format
msgid "Failed to rename: %(error)s"
msgstr "Ошибка переименования: %(error)s"
#: ../flask_adminex/ext/sqlamodel/filters.py:35
msgid "equals"
msgstr "равно"
#: ../flask_adminex/ext/sqlamodel/filters.py:43
msgid "not equal"
msgstr "не равно"
#: ../flask_adminex/ext/sqlamodel/filters.py:52
msgid "contains"
msgstr "содержит"
#: ../flask_adminex/ext/sqlamodel/filters.py:61
msgid "not contains"
msgstr "не содержит"
#: ../flask_adminex/ext/sqlamodel/filters.py:69
msgid "greater than"
msgstr "больше чем"
#: ../flask_adminex/ext/sqlamodel/filters.py:77
msgid "smaller than"
msgstr "меньше чем"
#: ../flask_adminex/ext/sqlamodel/form.py:37
msgid "Already exists."
msgstr "Уже существует."
#: ../flask_adminex/ext/sqlamodel/view.py:504
#, python-format
msgid "Failed to create model. %(error)s"
msgstr "Ошибка создания записи: %(error)s"
#: ../flask_adminex/ext/sqlamodel/view.py:519
#, python-format
msgid "Failed to update model. %(error)s"
msgstr "Ошибка обновления записи: %(error)s"
#: ../flask_adminex/ext/sqlamodel/view.py:534
#, python-format
msgid "Failed to delete model. %(error)s"
msgstr "Ошибка удаления записи: %(error)s"
#: ../flask_adminex/model/base.py:742
msgid "Model was successfully created."
msgstr "Запись была создана."
#: ../flask_adminex/model/filters.py:82
msgid "Yes"
msgstr "Да"
#: ../flask_adminex/model/filters.py:83
msgid "No"
msgstr "Нет"
#: ../flask_adminex/templates/admin/lib.html:105
msgid "Submit"
msgstr "Отправить"
#: ../flask_adminex/templates/admin/lib.html:110
msgid "Cancel"
msgstr "Отмена"
#: ../flask_adminex/templates/admin/file/list.html:7
msgid "Root"
msgstr "Корень"
#: ../flask_adminex/templates/admin/file/list.html:42
#, python-format
msgid "Are you sure you want to delete \\'%(name)s\\' recursively?"
msgstr "Вы уверены что хотите рекурсивно удалить \\'%(name)s\\'?"
#: ../flask_adminex/templates/admin/file/list.html:50
#, python-format
msgid "Are you sure you want to delete \\'%(name)s\\'?"
msgstr "Вы уверены что хотите удалить \\'%(name)s\\'?"
#: ../flask_adminex/templates/admin/file/list.html:75
msgid "Upload File"
msgstr "Залить файл"
#: ../flask_adminex/templates/admin/file/list.html:78
msgid "Create Directory"
msgstr "Создать директорию"
#: ../flask_adminex/templates/admin/file/rename.html:5
#, python-format
msgid "Please provide new name for %(name)s"
msgstr "Введите новое имя для %(name)s"
#: ../flask_adminex/templates/admin/model/create.html:11
msgid "Save and Add"
msgstr "Сохранить и Добавить"
#: ../flask_adminex/templates/admin/model/create.html:16
#: ../flask_adminex/templates/admin/model/list.html:12
msgid "List"
msgstr "Список"
#: ../flask_adminex/templates/admin/model/create.html:19
#: ../flask_adminex/templates/admin/model/list.html:16
msgid "Create"
msgstr "Создать"
#: ../flask_adminex/templates/admin/model/list.html:23
msgid "Add Filter"
msgstr "Добавить Фильтр"
#: ../flask_adminex/templates/admin/model/list.html:44
msgid "Search"
msgstr "Поиск"
#: ../flask_adminex/templates/admin/model/list.html:57
msgid "Apply"
msgstr "Применить"
#: ../flask_adminex/templates/admin/model/list.html:59
msgid "Reset Filters"
msgstr "Сброс Фильтров"
#: ../flask_adminex/templates/admin/model/list.html:67
msgid "Remove Filter"
msgstr "Убрать Фильтр"
#: ../flask_adminex/templates/admin/model/list.html:128
msgid "You sure you want to delete this item?"
msgstr "Вы уверены что хотите удалить эту запись?"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment