
    soj                     .    d dl mZ  G d de          ZdS )    )phrasesc                   6     e Zd ZdZ fdZddZd Zd Z xZS )LazyPhraseDictaZ  
    A dict that is built once at import time with phrase *constant names* (strings) as
    values instead of resolved phrase strings, and resolves them against the currently
    active language every time a value is read.

    This is needed because dicts such as `{SomeEnum.A: phrases.SOME_TEXT}` are normally
    built once when the module is first imported, "freezing" the phrase in whatever
    language was active at that time (usually the default language, since imports happen
    at Bot startup). By storing the phrase constant *name* instead of its value, and
    resolving it lazily on every access, the dict stays correct no matter which language
    is active when it's read.

    Usage:
        MY_DICT = LazyPhraseDict({MyEnum.A: "SOME_PHRASE_CONSTANT_NAME"})
        MY_DICT[MyEnum.A]  # Resolved in the language currently active

        # If the phrase needs .format() args that are already known at import time
        # (e.g. static Env values), store a tuple of (constant_name, args_tuple) instead:
        MY_DICT = LazyPhraseDict({MyEnum.A: ("SOME_PHRASE_CONSTANT_NAME", (arg1, arg2))})
    c                     t                                          |          }t          |t                    r"|\  }} t	          t
          |          j        | S t	          t
          |          S N)super__getitem__
isinstancetuplegetattrr   format)selfkeyvaluephrase_constant_nameformat_args	__class__s         /app/src/utils/LazyPhraseDict.pyr	   zLazyPhraseDict.__getitem__   sc    ##C((eU## 	O05- +@77$899@+NNw&&&    Nc                 8    	 | |         S # t           $ r |cY S w xY wr   )KeyError)r   r   defaults      r   getzLazyPhraseDict.get#   s5    	9 	 	 	NNN	s   
 c                 D      fd                                  D             S )Nc                      g | ]
}|         S  r   .0r   r   s     r   
<listcomp>z)LazyPhraseDict.values.<locals>.<listcomp>*   s    111cS	111r   keysr   s   `r   valueszLazyPhraseDict.values)   s%    1111TYY[[1111r   c                 D      fd                                  D             S )Nc                 $    g | ]}||         fS r   r   r   s     r   r   z(LazyPhraseDict.items.<locals>.<listcomp>-   s"    888Sd3i 888r   r    r"   s   `r   itemszLazyPhraseDict.items,   s%    8888DIIKK8888r   r   )	__name__
__module____qualname____doc__r	   r   r#   r&   __classcell__)r   s   @r   r   r      st         *' ' ' ' '   2 2 29 9 9 9 9 9 9r   r   N)	resourcesr   dictr   r   r   r   <module>r.      sK         )9 )9 )9 )9 )9T )9 )9 )9 )9 )9r   