nicosantangelo / sublime-text-i18n-rails

Sublime Text 2/3 package for Rails Internationalization
MIT License
18 stars 3 forks source link

Ability to add subfolders #13

Open albertodega opened 10 years ago

albertodega commented 10 years ago

Hi guys. I've a prettu strange structure in my yml files: they actually doesnt reflect the /view/[model] path standard, so the package is not able to navigate in files looking for translations. Could you please provide a method to make the searching method like how rails does?

the magic is made by rails by the following settings in my application.rb, it would be really awesome if the package could work the same!

config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
config.i18n.fallbacks = [:it, :en]

thank you!

nicosantangelo commented 10 years ago

Hello!, I think this is a good idea. It's been a while since I've opened this project but I'll give it a go.

Could you please post a simplification of your folder structure? so I have a real world example to work with :).

Thanks!

albertodega commented 10 years ago

here you are!

config/locales
├── bootstrap
│   ├── en.yml
│   └── it.yml
├── devise
│   ├── en.yml
│   └── it.yml
├── devise.security_extension.de.yml
├── devise.security_extension.en.yml
├── devise.security_extension.it.yml
├── en.yml
├── intranet
│   ├── cms
│   │   └── it.yml
│   ├── common
│   │   └── it.yml
│   ├── counter
│   │   └── it.yml
│   ├── counter_clone
│   │   └── it.yml
│   ├── films
│   │   └── it.yml
│   ├── fiscal
│   │   └── it.yml
│   ├── ims
│   │   └── it.yml
│   ├── reports
│   │   └── it.yml
│   ├── roles
│   │   └── it.yml
│   ├── service_communications
│   │   └── it.yml
│   ├── shared
│   │   └── top_menu
│   │       └── it.yml
│   ├── shift_schedules
│   │   └── it.yml
│   ├── subsystem
│   │   └── it.yml
│   ├── theaters
│   │   └── it.yml
│   └── users
│       └── it.yml
├── it-CH.yml
├── it.yml
└── messaging
    └── it.yml

thank you!

nicosantangelo commented 10 years ago

Hello!

I have a working version of this on the add_subfolders branch. To make it work, you have to set the recursive setting to true, so the package will search on all the files on your /config/locales/ folder.

I was going to add a additional_paths setting instead of a recursive one, but it think this way is more straightforward.

The thing is, right now this package has a Sublime Text 3 (master) and Sublime Text 2 (st2) branch, which meas that for each change I make, I have to replicate it on the other branch. So, instead of merging this directly into master, I'm going to try combining the branches, and then make a release of that.

The bad news is that may take me a while, so if you want to give this a try, you could clone the branch on your sublime packages folder, it would be awesome to get some feedback. Otherwise I will let you know here when I'm done merging the branches so you can use the package control version.

Thanks for the suggestion, and let me know!

albertodega commented 10 years ago

hi nico! i've just tried with the branch on st3, setted up the user package config as follows:

{
  "recursive": true
}

but it doesn't seem to work: it always search only in the root folder of the locales. also, it seems that it is pretty slow to search in keys, but i don't know if this is a issue of the new branch or not. Tell me if i can help debugging and thank you for your time!

nicosantangelo commented 10 years ago

I've just tried on Windows with a folder structure similar to yours (removing the package with Package Control and then cloning it on AppData\Roaming\Sublime Text 3\Packages and checkouting add_subdolders) and the command Go to YAML file gives me the following result: i18n

I'm more inclined to think that if it's not working for you it's a bug on the package (I'm still not that confident on the implementation), but, do you get a similar result?

nicosantangelo commented 10 years ago

Did it work for you?

I want to test this a bit more and merge it into master, I would love your feedback (if you can of course).

albertodega commented 9 years ago

Hei nico, sorry for the longest delay ever seen on github, but i switched my effort on another project in the last month and i've been able to go back to those funny things only today and... It works, i don't know what i did wrong the last time, but it actually works! I'm testing it right now, i'll tell you asap in case of problem or i everything works as expected! Thank you very much and, again, sorry for the delay!

edit: first thing first: if the toggle key is enabled, on every save it take about 5 seconds locking down sublime and not permitting any action until it has finished scraping again the locales. Maybe this is caused by the huge amount of yamls i have in my project?

nicosantangelo commented 9 years ago

Don't worry about the time!! I thought you just lost interest ^^, this time you may have to wait for me a bit because I'm with my last exams :).

I think that if you have a huge amount of YAMLs or keys the performance it's going to decrease...I don't have any cache in place to mitigate this, I could give it a try (just caching the file contents should be enough)