Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm stuck on I18nFileLoadError: no loader available for extension yml #38

Open
bsa7 opened this issue Nov 23, 2022 · 4 comments
Open

I'm stuck on I18nFileLoadError: no loader available for extension yml #38

bsa7 opened this issue Nov 23, 2022 · 4 comments

Comments

@bsa7
Copy link

bsa7 commented Nov 23, 2022

Hi, i'm novice in python and stuck on problem with i18n
It works on development and production server
pass test with ward on my local machine, but in github action fails.

log:

Run ./script/run_tests.sh
Run all tests

$ pwd:
/home/runner/work/pretrained-app/pretrained-app

$ls
#####################5
total 68K
drwxr-xr-x  [7](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:8) runner docker 4.0K Nov 23 17:3[8](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:9) .
drwxr-xr-x 11 runner docker 4.0K Nov 23 17:38 ..
-rw-r--r--  1 runner docker  20K Nov 23 17:38 .pylintrc
-rw-r--r--  1 runner docker  500 Nov 23 17:38 Dockerfile
drwxr-xr-x  7 runner docker 4.0K Nov 23 17:38 app
drwxr-xr-x  4 runner docker 4.0K Nov 23 17:38 config
-rw-r--r--  1 runner docker    0 Nov 23 17:38 conftest.py
-rw-r--r--  1 runner docker  166 Nov 23 17:38 development_server.py
drwxr-xr-x  2 runner docker 4.0K Nov 23 17:38 log
drwxr-xr-x  2 runner docker 4.0K Nov 23 17:38 monkeypatches
-rw-r--r--  1 runner docker  188 Nov 23 17:38 production_server.py
-rw-r--r--  1 runner docker   50 Nov 23 17:38 pytest.ini
-rw-r--r--  1 runner docker  264 Nov 23 17:38 requirements.txt
drwxr-xr-x  8 runner docker 4.0K Nov 23 17:38 tests

#####################7
$ ls ../.

total 64K
drwxr-xr-x 11 runner docker 4.0K Nov 23 17:38 .
drwxr-xr-x  3 runner docker 4.0K Nov 23 17:38 ..
-rw-r--r--  1 runner docker    [9](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:10) Nov 23 17:38 .envrc
drwxr-xr-x  8 runner docker 4.0K Nov 23 17:38 .git
drwxr-xr-x  3 runner docker 4.0K Nov 23 17:38 .github
-rw-r--r--  1 runner docker   88 Nov 23 17:38 .gitignore
-rw-r--r--  1 runner docker   29 Nov 23 17:38 .tool-versions
-rw-r--r--  1 runner docker 1.3K Nov 23 17:38 README.md
drwxr-xr-x  7 runner docker 4.0K Nov 23 17:38 api
drwxr-xr-x  2 runner docker 4.0K Nov 23 17:38 deploy
drwxr-xr-x  3 runner docker 4.0K Nov 23 17:38 docker
-rw-r--r--  1 runner docker  744 Nov 23 17:38 docker-compose.yml
drwxr-xr-x  3 runner docker 4.0K Nov 23 17:38 docs
drwxr-xr-x  4 runner docker 4.0K Nov 23 17:38 frontend
drwxr-xr-x  2 runner docker 4.0K Nov 23 17:38 script
drwxr-xr-x  4 runner docker 4.0K Nov 23 17:38 stages

#####################9
$ ls ../../.
total 12K
drwxr-xr-x  3 runner docker 4.0K Nov 23 17:38 .
drwxr-xr-x  6 runner root   4.0K Nov 23 17:38 ..
drwxr-xr-x [11](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:12) runner docker 4.0K Nov 23 17:38 pretrained-app
#####################11
total 24K


drwxr-xr-x  6 runner root   4.0K Nov 23 17:38 .
drwxr-xr-x [15](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:16) runner docker 4.0K Nov 23 [17](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:18):38 ..
drwxr-xr-x  3 runner docker 4.0K Nov [23](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:24) 17:[38](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:39) _PipelineMapping
drwxr-xr-x  3 runner docker 4.0K Nov 23 17:38 _actions
drwxr-xr-x  4 runner docker 4.0K Nov 23 17:[39](https://github.com/bsa7/pretrained-app/actions/runs/3534337993/jobs/5931088769#step:5:40) _temp
drwxr-xr-x  3 runner docker 4.0K Nov 23 17:38 pretrained-app
/home/runner/work/pretrained-app/pretrained-app/api

test.log trimmed
...

│ /resource_loader.py:115 in recursive_search_dir                          │  
  │                                                                          │  
  │   112 │   seeked_file = config.get('filename_format').format(namespace=s │  
  │   113 │   dir_content = os.listdir(os.path.join(root_dir, directory))    │  
  │   114 │   if seeked_file in dir_content:                                 │  
  │ ❱ 115 │   │   load_translation_file(os.path.join(directory, seeked_file) │  
  │   116 │   elif splitted_namespace[0] in dir_content:                     │  
  │   117 │   │   recursive_search_dir(splitted_namespace[1:], os.path.join( │  
  │   118                                                                    │  
  │                                                                          │  
  │ ╭─────────────────────────────── locals ───────────────────────────────╮ │  
  │ │        dir_content = ['messages.en.yml']                             │ │  
  │ │          directory = ''                                              │ │  
  │ │             locale = 'en'                                            │ │  
  │ │           root_dir = '/home/runner/work/pretrained-app/pretrained-a… │ │  
  │ │        seeked_file = 'messages.en.yml'                               │ │  
  │ │ splitted_namespace = ['messages']                                    │ │  
  │ ╰──────────────────────────────────────────────────────────────────────╯ │  
  │                                                                          │  
  │ /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/i18n │  
  │ /resource_loader.py:72 in load_translation_file                          │  
  │                                                                          │  
  │    69 def load_translation_file(filename, base_directory, locale=config. │  
  │    70 │   skip_locale_root_data = config.get('skip_locale_root_data')    │  
  │    71 │   root_data = None if skip_locale_root_data else locale          │  
  │ ❱  72 │   translations_dic = load_resource(os.path.join(base_directory,  │  
  │    73 │   namespace = get_namespace_from_filepath(filename)              │  
  │    74 │   load_translation_dic(translations_dic, namespace, locale)      │  
  │    75                                                                    │  
  │                                                                          │  
  │ ╭─────────────────────────────── locals ───────────────────────────────╮ │  
  │ │        base_directory = '/home/runner/work/pretrained-app/pretraine… │ │  
  │ │              filename = 'messages.en.yml'                            │ │  
  │ │                locale = 'en'                                         │ │  
  │ │             root_data = 'en'                                         │ │  
  │ │ skip_locale_root_data = False                                        │ │  
  │ ╰──────────────────────────────────────────────────────────────────────╯ │  
  │                                                                          │  
  │ /opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/i18n │  
  │ /resource_loader.py:23 in load_resource                                  │  
  │                                                                          │  
  │    20 def load_resource(filename, root_data):                            │  
  │    21 │   extension = os.path.splitext(filename)[1][1:]                  │  
  │    22 │   if extension not in loaders:                                   │  
  │ ❱  23 │   │   raise I18nFileLoadError("no loader available for extension │  
  │    24 │   return getattr(loaders[extension], "load_resource")(filename,  │  
  │    25                                                                    │  
  │    26                                                                    │  
  │                                                                          │  
  │ ╭─────────────────────────────── locals ───────────────────────────────╮ │  
  │ │ extension = 'yml'                                                    │ │  
  │ │  filename = '/home/runner/work/pretrained-app/pretrained-app/api/co… │ │  
  │ │ root_data = 'en'                                                     │ │  
  │ ╰──────────────────────────────────────────────────────────────────────╯ │  
  ╰──────────────────────────────────────────────────────────────────────────╯  
  I18nFileLoadError: no loader available for extension yml                      
                                                                                
  Captured stdout                                                               
                                                                                
    Initialize application log for environment "environment_name='test'"        
    self.fix_pathname(os.path.abspath(__file__ + "/../../"))='/home/runner/work/pretrained-app/pretrained-app/api'           
    self.fix_pathname(os.path.abspath(__file__ + "/../../"))='/home/runner/work/pretrained-app/pretrained-app/api'           
    self.fix_pathname(os.path.abspath(__file__ + "/../../"))='/home/runner/work/pretrained-app/pretrained-app/api'           

    I18n initialization. Locale folder:                                         
    /home/runner/work/pretrained-app/pretrained-app/api/config/locales,         
    root_path: /home/runner/work/pretrained-app/pretrained-app/api              

    i18n.config.settings={'filename_format': '{namespace}.{locale}.{format}',   
    'file_format': 'yml', 'available_locales': ['en'], 'load_path':             
    ['/home/runner/work/pretrained-app/pretrained-app/api/config/locales'],     
    'locale': 'en', 'fallback': 'en', 'placeholder_delimiter': '%',             
    'error_on_missing_translation': True, 'error_on_missing_placeholder': False,
    'error_on_missing_plural': False, 'encoding': 'utf-8',                      
    'namespace_delimiter': '.', 'plural_few': 5, 'skip_locale_root_data': False,
    'enable_memoization': False}                                                
                                                                                

────────────────────────────────────────────────────────────────────────────────
╭──────────── Results ────────────╮
│  9  Tests Encountered           │
│  6  Passes             (66.7%)  │
│  3  Failures           (33.3%)  │
╰─────────────────────────────────╯
──────────────────────────── FAILED in 3.97 seconds ────────────────────────────
Error: Process completed with exit code 1.

@bsa7
Copy link
Author

bsa7 commented Nov 24, 2022

You are writing here:

If you want to use YAML to store your translations, use
pip install python-i18n[YAML]

But, when i run that command, i'd see next:

$ pip install python-i18n[YAML]
zsh: => no matches found: python-i18n[YAML]

@sectasy0
Copy link

sectasy0 commented Jan 9, 2023

@bsa7 This package seems abandoned, if you still need an internationalization package for python check out this library https://github.com/sectasy0/pyi18n

@deajan
Copy link

deajan commented Mar 22, 2023

There's also the fork here https://github.com/Krutyi-4el/python-i18n which is a drop-in replacement and fixes quite a lot of issues.

@jurest82
Copy link

"I18n FileLoadError: no loader available for extension yml", means that you dont have installed "pyyaml", add this dependency to your environment and your app will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants