GRAPHIC: New Entity Operations™ Alpha Logo

EntityScript



core_language




# -*- coding: utf-8 -*-
"""
COPYRIGHT (C) 2020-2023 NEW ENTITY OPERATIONS INC. ALL RIGHTS RESERVED
INSTANCE: core_language
MODIFIED: 2023/05/12
OVERVIEW:

core_language can serve as a language localization script and enforce outputs
based on provided language pack plugins. The plugins aren't available by
default, and when they're tied in, they should be in utf-8

If you decide to build in comparison driven-verfication methods for one
translation to the next,, you can provide the hooks for checking them here.

This would include any classes to compare on the fly data strings of one locale
to a desired data-string of another if you're extending beyond utf-8

"""
__version__ = "0.0.8"
__author__ = "Ryan McKenna"
__copyright__ = "Copyright (C) 2020-2023 New Entity Operations Inc."
__credits__ = [
 "Ryan McKenna",
 "New Entity Operations Inc.", "New Entity Operations, LLC"]
__email__ = "Operator@NewEntityOperations.com"
__license__ = "New Entity License"
__maintainer__ = "Ryan McKenna"
__status__ = "Production"

## MODE-> facilities
from MODE.facilities import MODULE_MATCHER_MAIN

## Imports: Custom
from core_middlelayer import (COPYRIGHT, language_code)

class LANG_PROPAGATE():
 """
 International Language Propogation logic.

 Not everything is here right now, but the program has been tested with some
 common alt-languages, such as French.

 Eventually, all the core interface elements will be mapped to language
 objects of either a default or customized type/kind. The linking will be done
 on the fly through the interface, but this script can feed that entity

 >>> import core_language
 >>> ## Create a LANG mapping object (simple)
 >>> core_language.LANG_PROPAGATE('en')
 
 """
 def __init__(self, language_code):
  """
  LANG_PROPAGATE() must run at the bottom of a module to capture all the
  output functions.

  each time a language mapping occurs, you will need invoke the translator
  each time those elements are mapped to any destination language definition.

  You can use a default setup/skeleton to populate chosen attributes.
  Use the following model
  a.) Base language: en
  b.) Base language: en MAPPED-TO-> Sub-language: LANGUAGEX

  There shouldn't be text pulled into the FRONTEND interface that doesn't
  first do a language lookup, if the origin language is not the output language.

  This can also help you pull in file-system encodings of various types, and
  convert them into the base-module language, en UTF-8. This also applies for
  checking various system and file language structures.

  Languages and other encoded variables should arrive here through a
  presentation ONLY.

  This transition should be occuring on formatted strings only, or one that
  is already considered a 'safe' object - in other words, it should be cleaned
  before doing the language translation to avoid potential priv
  escalation attacks.

  This is the skeleton code
  """
  if language_code == 'en':
   self.PROPAGATE_ENGLISH()
  elif language_code == 'es':
   self.PROPAGATE_SPANISH()
  else:
   print("No other languages are offered in the preview build")

  def PROPAGATE_ENGLISH(self):
   """
   Base language: en
   """
   LANG_PROPAGATE.COPYRIGHT = COPYRIGHT

  def PROPAGATE_SPANISH(self):
   """
   Base language: en to Sub-language: es
   """
  LANG_PROPAGATE.COPYRIGHT = 'Derechos de autor'

## Default runner
if __name__ == MODULE_MATCHER_MAIN:
 LANG_PROPAGATE(language_code)



Return HOME