当前位置: 首页>>代码示例>>Python>>正文


Python L10n.init方法代码示例

本文整理汇总了Python中dNG.data.text.l10n.L10n.init方法的典型用法代码示例。如果您正苦于以下问题:Python L10n.init方法的具体用法?Python L10n.init怎么用?Python L10n.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dNG.data.text.l10n.L10n的用法示例。


在下文中一共展示了L10n.init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _render_table

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def _render_table(self):
        """
Renders the table and returns a (X)HTML table.

:return: (str) XHTML for the rendered table
:since:  v0.2.00
        """

        if (not isinstance(self.table, Abstract)): raise ValueException("Missing table instance to render")
        if (self.table_id is None): self.table_id = "pas_http_table_{0:d}".format(id(self))

        L10n.init("pas_http_table")

        limit = self.table.get_limit()
        row_count = self.table.get_row_count()

        self.pages = (1 if (row_count == 0) else ceil(float(row_count) / limit))

        pages = (self.page_limit if (self.page_limit > 0) else self.pages)
        self.table.set_offset(0 if (self.page < 1 or self.page > pages) else (self.page - 1) * limit)

        if (self.sort_column_key != ""): self.table.add_sort_definition(self.sort_column_key, self.sort_direction)

        if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("table_sprite.min.css")

        _return = self._render_table_header()
        _return += self._render_table_rows()
        _return += self._render_table_footer()

        return _return
开发者ID:dNG-git,项目名称:pas_http_table,代码行数:32,代码来源:table_mixin.py

示例2: execute_new

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
	def execute_new(self, is_save_mode = False):
	#
		"""
Action for "new"

:since: v0.1.00
		"""

		form_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_id", "")).strip()
		form_field_id = InputFilter.filter_control_chars(self.request.get_dsd("oform_field_id", "")).strip()

		L10n.init("pas_http_core_form")

		form = FormProcessor(form_id)
		form.set_form_render_id(Binary.str(hexlify(urandom(16))))

		if (is_save_mode): form.set_input_available()

		self._apply_new_form(form)

		if (is_save_mode and form.check()):
		#
			entry_data = self._save_new_form(form)

			form_store = form.get_form_store()
			form_store_dict = form_store.get_value_dict()
			form_store_field_id = "form_api_dynamic_{0}".format(form_field_id)

			entry_list = form_store_dict.get(form_store_field_id, [ ])
			entry_list.append(entry_data)

			form_store_dict[form_store_field_id] = entry_list
			form_store.set_value_dict(form_store_dict)

			self._set_destroy_dom_result()
		#
		else:
		#
			content = { "title": self._get_form_action_new_title(),
			            "on_closed_query": Link().build_url(Link.TYPE_QUERY_STRING, { "__request__": True, "a": "get" })
			          }

			content['form'] = { "object": form,
			                    "url_parameters": { "__request__": True,
			                                        "a": "new-save"
			                                      },
			                    "button_title": "core_continue"
			                  }

			method = (self._set_replace_dom_oset_result
			          if (is_save_mode) else
			          self._set_append_overlay_dom_oset_result
			         )

			method("dynamic_form.overlay", content)
开发者ID:dNG-git,项目名称:pas_http_dynamic_form,代码行数:57,代码来源:abstract.py

示例3: execute_delete

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def execute_delete(self):
        """
Action for "delete"

:since: v0.2.00
        """

        cid = InputFilter.filter_file_path(self.request.get_dsd("mcid", ""))

        source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
        target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()

        if (source_iline == ""): source_iline = "m=mp;a=list_root_containers"
        if (target_iline == ""): target_iline = source_iline

        L10n.init("mp_core")

        session = (self.request.get_session() if (self.request.is_supported("session")) else None)
        user_profile = (None if (session is None) else session.get_user_profile())

        if (user_profile is None
            or (not user_profile.is_type("ad"))
           ): raise TranslatableError("core_access_denied", 403)

        try: mp_entry = MpEntry.load_id(cid)
        except NothingMatchedException as handled_exception: raise TranslatableError("mp_core_cid_invalid", 404, _exception = handled_exception)

        if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")

        Link.set_store("servicemenu",
                       Link.TYPE_RELATIVE_URL,
                       L10n.get("core_back"),
                       { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
                       icon = "mini-default-back",
                       priority = 7
                      )

        if (not DatabaseTasks.is_available()): raise TranslatableException("pas_core_tasks_daemon_not_available")

        mp_entry.delete()

        database_tasks = DatabaseTasks.get_instance()
        database_tasks.add("dNG.pas.upnp.Resource.onDeleted.{0}".format(cid), "dNG.pas.upnp.Resource.onDeleted", 1, container_id = cid)
        database_tasks.add("dNG.pas.upnp.Resource.onRootContainerDeleted.{0}".format(cid), "dNG.pas.upnp.Resource.onRootContainerDeleted", 1, container_id = cid)

        target_iline = re.sub("\\_\\w+\\_\\_", "", target_iline)

        NotificationStore.get_instance().add_completed_info(L10n.get("mp_core_done_root_container_delete"))

        Link.clear_store("servicemenu")

        redirect_request = PredefinedHttpRequest()
        redirect_request.set_iline(target_iline)
        self.request.redirect(redirect_request)
开发者ID:dNG-git,项目名称:mp_core,代码行数:56,代码来源:root_container.py

示例4: init_control_l10n

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
def init_control_l10n(params, last_return = None):
    """
Called for "dNG.pas.http.l10n.upnp.Control.init"

:param params: Parameter specified
:param last_return: The return value from the last hook called.

:since: v0.2.00
    """

    L10n.init("mp_core")
    return last_return
开发者ID:dNG-git,项目名称:mp_core,代码行数:14,代码来源:mp_core.py

示例5: __init__

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def __init__(self, l10n = None):
        """
Constructor __init__(SecIDUpdatedEMailRenderer)

:param l10n: L10n instance

:since: v0.2.00
        """

        EMailRenderer.__init__(self, l10n)

        L10n.init("pas_http_user", self.l10n.get_lang())
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:14,代码来源:sec_id_updated_email_renderer.py

示例6: execute_logout

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def execute_logout(self):
        """
Action for "logout"

:since: v0.2.00
        """

        source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()
        target_iline = InputFilter.filter_control_chars(self.request.get_dsd("target", "")).strip()

        if (target_iline == ""):
            if (Settings.is_defined("pas_http_user_logout_default_target_lang_{0}".format(self.request.get_lang()))): target_iline = Settings.get("pas_http_user_logout_default_target_lang_{0}".format(self.request.get_lang()))
            elif (Settings.is_defined("pas_http_user_logout_default_target")): target_iline = Settings.get("pas_http_user_logout_default_target")
            else: target_iline = source_iline
        #

        L10n.init("pas_http_user")

        if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")

        Link.set_store("servicemenu",
                       Link.TYPE_RELATIVE_URL,
                       L10n.get("core_back"),
                       { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
                       icon = "mini-default-back",
                       priority = 7
                      )

        if (not self.request.is_supported("session")): raise TranslatableError("core_unknown_error", 500)

        session = Session.load(session_create = False)

        if (session is not None):
            session.delete()
            self.request.set_session(None)
        #

        Link.clear_store("servicemenu")

        target_iline = re.sub("\\_\\_\\w+\\_\\_", "", target_iline)

        redirect_request = PredefinedHttpRequest()
        redirect_request.set_module("output")
        redirect_request.set_service("http")
        redirect_request.set_action("done")

        redirect_request.set_parameter_chained("title", L10n.get("pas_http_user_logout"))
        redirect_request.set_parameter_chained("message", L10n.get("pas_http_user_done_logout"))
        redirect_request.set_parameter_chained("target_iline", target_iline)

        self.request.redirect(redirect_request)
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:53,代码来源:status.py

示例7: execute_subscribe

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
	def execute_subscribe(self):
	#
		"""
Action for "subscribe"

:since: v0.1.00
		"""

		_id = InputFilter.filter_file_path(self.request.get_dsd("oid", ""))

		source_iline = InputFilter.filter_control_chars(self.request.get_dsd("source", "")).strip()

		L10n.init("pas_http_datalinker")
		L10n.init("pas_http_subscription")

		if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")

		if (len(source_iline) > 0):
		#
			Link.set_store("servicemenu",
			               Link.TYPE_RELATIVE_URL,
			               L10n.get("core_back"),
			               { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
			               icon = "mini-default-back",
			               priority = 7
			              )
		#

		session = (self.request.get_session() if (self.request.is_supported("session")) else None)
		subscription_handler = self._get_subscription_handler(_id)

		if (subscription_handler is None): NotificationStore.get_instance().add_error(L10n.get("errors_pas_http_subscription_not_subscribable"))
		elif (not subscription_handler.is_subscribable_for_session_user(session)): NotificationStore.get_instance().add_error(L10n.get("errors_pas_http_subscription_not_subscribable"))
		else:
		#
			subscription_handler.set_session(session)
			if (not subscription_handler.is_subscribed()): subscription_handler.subscribe()

			NotificationStore.get_instance().add_completed_info(L10n.get("pas_http_subscription_done_subscribe"))
		#

		source_iline = re.sub("\\_\\_\\w+\\_\\_", "", source_iline)

		Link.clear_store("servicemenu")

		redirect_request = PredefinedHttpRequest()
		redirect_request.set_iline(source_iline)
		self.request.redirect(redirect_request)
开发者ID:dNG-git,项目名称:pas_http_subscription,代码行数:50,代码来源:datalinker.py

示例8: get_view

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def get_view(self):
        """
Action for "view"

:since: v1.0.0
        """

        cid = InputFilter.filter_file_path(self.request.get_parameter("cid", ""))

        source_iline = InputFilter.filter_control_chars(self.request.get_parameter("source", "")).strip()

        L10n.init("pas_http_core_contentfile")

        Settings.read_file("{0}/settings/pas_http_contentfiles.json".format(Settings.get("path_data")))

        contentfiles = Settings.get("pas_http_contentfiles_list", { })
        if (type(contentfiles) is not dict): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)

        if (source_iline != ""):
            if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.css")

            Link.set_store("servicemenu",
                           Link.TYPE_RELATIVE_URL,
                           L10n.get("core_back"),
                           { "__query__": re.sub("\\_\\_\\w+\\_\\_", "", source_iline) },
                           icon = "mini-default-back",
                           priority = 7
                          )
        #

        if (cid not in contentfiles
            or "title" not in contentfiles[cid]
            or "filepath" not in contentfiles[cid]
           ): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)

        file_content = FileContent.read(contentfiles[cid]['filepath'])
        if (file_content is None): raise TranslatableError("pas_http_core_contentfile_cid_invalid", 404)

        if (path.splitext(contentfiles[cid]['filepath'])[1].lower() == ".ftg"): file_content = FormTags.render(file_content)

        content = { "title": contentfiles[cid]['title'],
                    "content": file_content
                  }

        self.response.init()
        self.response.page_title = contentfiles[cid]['title']

        self.response.add_oset_content("core.simple_content", content)
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:50,代码来源:contentfile.py

示例9: execute_services

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def execute_services(self):
        """
Action for "services"

:since: v0.2.00
        """

        L10n.init("pas_http_user")

        content = { "title": L10n.get("pas_http_user_services"),
                    "service_list": { "file": "{0}/settings/lists/pas_user.service.json".format(Settings.get("path_data")) }
                  }

        self.response.init()
        self.response.set_title(content['title'])
        self.response.add_oset_content("core.service_list", content)
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:18,代码来源:index.py

示例10: execute_get

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
	def execute_get(self):
	#
		"""
Action for "get"

:since: v0.1.00
		"""

		L10n.init("pas_http_core_form")

		entry_list = self._get_form_field_list()

		self._set_replace_dom_result("<div>{0}\n{1}</div>".format(self._get_view_content(entry_list),
		                                                          self._get_new_entry_link_content()
		                                                         ),
		                             on_replaced = "pas/HttpJsonApiDomEditor.min",
		                             type = "link_activated"
		                            )
开发者ID:dNG-git,项目名称:pas_http_dynamic_form,代码行数:20,代码来源:abstract.py

示例11: __init__

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def __init__(self, l10n = None):
        """
Constructor __init__(VerificationEMailRenderer)

:param l10n: L10n instance

:since: v0.2.00
        """

        EMailRenderer.__init__(self, l10n)

        self.verification_details = None
        """
Details text about what will be verified with the task link
        """

        Settings.read_file("{0}/settings/pas_http.json".format(Settings.get("path_data")))
        Settings.read_file("{0}/settings/pas_http_user.json".format(Settings.get("path_data")))

        L10n.init("pas_http_user", self.l10n.get_lang())
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:22,代码来源:verification_email_renderer.py

示例12: execute_done

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def execute_done(self):
        """
Action for "done"

:since: v1.0.0
        """

        if (not isinstance(self.request, AbstractInnerRequest)): raise TranslatableException("pas_http_core_400", 400)

        parameters_chained = self.request.parameters_chained
        is_parameters_chained_valid = ("title" in parameters_chained and "message" in parameters_chained)

        if (not is_parameters_chained_valid): raise TranslatableException("pas_http_core_500")

        l10n = (L10n.get_instance(parameters_chained['lang'])
                if ("lang" in parameters_chained) else
                L10n.get_instance()
               )

        L10n.init("core", l10n.lang)

        content = { "title": parameters_chained['title'],
                    "title_task_done": l10n.get("core_title_task_done"),
                    "message": parameters_chained['message']
                  }

        if ("target_iline" in parameters_chained):
            content['link_title'] = l10n.get("core_continue")

            target_iline = re.sub("\\_\\_\\w+\\_\\_", "", parameters_chained['target_iline'])
            content['link_url'] = Link().build_url(Link.TYPE_RELATIVE_URL, { "__query__": target_iline })
        #

        self.response.init()
        self.response.page_title = parameters_chained['title']

        self.response.add_oset_content("core.done", content)
开发者ID:dNG-git,项目名称:pas_http_core,代码行数:39,代码来源:http.py

示例13: execute_list_root_containers

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def execute_list_root_containers(self):
        """
Action for "list_root_containers"

:since: v0.2.00
        """

        page = InputFilter.filter_int(self.request.get_dsd("mpage", 1))

        L10n.init("mp_core")

        session = (self.request.get_session() if (self.request.is_supported("session")) else None)
        user_profile = (None if (session is None) else session.get_user_profile())

        if (user_profile is None
            or (not user_profile.is_type("ad"))
           ): raise TranslatableError("core_access_denied", 403)

        if (self.response.is_supported("html_css_files")): self.response.add_theme_css_file("mini_default_sprite.min.css")

        Link.set_store("servicemenu",
                       (Link.TYPE_RELATIVE_URL | Link.TYPE_JS_REQUIRED),
                       L10n.get("mp_core_root_container_new"),
                       { "m": "mp", "s": "root_container", "a": "new" },
                       icon = "mini-default-option",
                       priority = 3
                      )

        content = { "title": L10n.get("mp_core_root_container_list"),
                    "entries": MpEntry.get_root_containers_count(),
                    "page": page
                  }

        self.response.init()
        self.response.set_title(content['title'])
        self.response.add_oset_content("mp.container", content)
开发者ID:dNG-git,项目名称:mp_core,代码行数:38,代码来源:index.py

示例14: run

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def run(self):
        """
Task execution

:since: v0.2.00
        """

        user_profile_class = NamedLoader.get_class("dNG.data.user.Profile")

        user_profile = user_profile_class.load_username(self.username)

        original_user_profile_data = user_profile.get_data_attributes(*self.values_changed.keys())

        user_profile.set_data_attributes(**self.values_changed)
        user_profile.save()

        DatabaseTasksProxy.get_instance().add("dNG.pas.user.Profile.onEdited.{0}".format(self.username),
                                              "dNG.pas.user.Profile.onEdited",
                                              1,
                                              user_profile_id = user_profile.get_id(),
                                              user_profile_data_changed = self.values_changed,
                                              original_user_profile_data = original_user_profile_data
                                             )

        task_data = DatabaseTasks.get_instance().get(self.vid)

        if (task_data is not None and "_task" in task_data):
            task_data['_task'].set_status_completed()
            task_data['_task'].save()
        #

        user_profile_data = user_profile.get_data_attributes("id", "name", "lang")

        L10n.init("core", user_profile_data['lang'])
        L10n.init("pas_core", user_profile_data['lang'])
        L10n.init("pas_http_user", user_profile_data['lang'])

        l10n = L10n.get_instance(user_profile_data['lang'])

        _return = PredefinedHttpRequest()
        _return.set_module("output")
        _return.set_service("http")
        _return.set_action("done")

        _return.set_parameter_chained("title", l10n.get("pas_http_user_title_change_profile"))
        _return.set_parameter_chained("message", l10n.get("pas_http_user_done_change_profile"))
        _return.set_parameter_chained("lang", l10n.get_lang())
        _return.set_parameter_chained("target_iline", "m=user;s=profile;lang={0};dsd=upid+{1}".format(user_profile_data['lang'], user_profile_data['id']))

        return _return
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:52,代码来源:changes_confirmed.py

示例15: run

# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import init [as 别名]
    def run(self):
        """
Task execution

:since: v0.2.00
        """

        user_profile_class = NamedLoader.get_class("dNG.data.user.Profile")

        user_profile = user_profile_class.load_username(self.username)
        user_profile.unlock()
        user_profile.save()

        database_tasks_proxy = DatabaseTasksProxy.get_instance()

        database_tasks_proxy.add("dNG.pas.user.Profile.updateSecID.{0}".format(self.username),
                                 "dNG.pas.user.Profile.updateSecID",
                                 1,
                                 username = self.username
                                )

        database_tasks_proxy.remove("dNG.pas.user.Profile.delete.{0}".format(self.username))

        task_data = DatabaseTasks.get_instance().get(self.vid)

        if (task_data is not None and "_task" in task_data):
            task_data['_task'].set_status_completed()
            task_data['_task'].save()
        #

        user_profile_data = user_profile.get_data_attributes("name", "lang")

        L10n.init("core", user_profile_data['lang'])
        L10n.init("pas_core", user_profile_data['lang'])
        L10n.init("pas_http_user", user_profile_data['lang'])

        l10n = L10n.get_instance(user_profile_data['lang'])

        _return = PredefinedHttpRequest()
        _return.set_module("output")
        _return.set_service("http")
        _return.set_action("done")

        _return.set_parameter_chained("title", l10n.get("pas_http_user_title_registration"))
        _return.set_parameter_chained("message", l10n.get("pas_http_user_done_registration"))
        _return.set_parameter_chained("lang", l10n.get_lang())
        _return.set_parameter_chained("target_iline", "m=user;s=status;a=login;lang={0}".format(user_profile_data['lang']))

        return _return
开发者ID:dNG-git,项目名称:pas_http_user,代码行数:51,代码来源:registration_validated.py


注:本文中的dNG.data.text.l10n.L10n.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。