Amber: Move src/locales to config/locales like Rails

Created on 27 May 2018  路  13Comments  路  Source: amberframework/amber

Description

Currently locales are on src/locales would nice to follow Rails convention here and move this folder to config/locales

Steps to Reproduce

Not applicable

Versions

Amber master (https://github.com/amberframework/amber/commit/975dc592b9fd40f94d6cff1c5d34512283d01fd0)

Additional Information

Related comment here: https://github.com/amberframework/amber/pull/814#issuecomment-392279084

/cc @eliasjpr @docelic

enhancement discussion

Most helpful comment

@eliasjpr Maybe we can follow @damianham approach on this, WDYT?, see: Modular recipe (BTW, I don't think we should use a recipe, but consider a modular structure like this)

This is out of scope. Amber strictly follow MVC the way rails does it if someone would like to structure their apps like the modular example you presented that is fine, but it is not part of the conventions Amber has set for the apps.

On another note, I do believe we should add support for a modular approach to mount another app like plugins. For now, I think this is not a big issue having the locales in the src directory.

All 13 comments

I don't see the added benefit, besides rails conventions. I can swing either way with this.

@faustinoaq Is it also a good idea to move the src/${project-name}.cr to the root of the project folder and rename to config.cr? Then all the application specific files would be in the src directory and all the Amber specific files will be in the config directory. In general, if Amber wants to standardize its layout based on Rails, this would definitely be a good time to do it prior to 1.0.

@conradwt Well, the main file inside src/ folder is a crystal idea, by example, if you try to create an amber project from scratch without amber cli (1) you can use crystal init app myapp and a "main" file is automatically generated on src/ folder and added to shard.yml target, so you can do shards build myapp to compile your project.

(1) https://docs.amberframework.org/amber/cookbook/from-scratch

@conradwt the src/{project_name}.cr is a crystal convention that we are supporting. As per the src/locales I understand that people are used to Rails convention but I don't the value that it brings by moving it outside, to me it does not make much difference and it works, for that reason I think this is not an issue.

@faustinoaq can you provide the added benefits of moving this to config/locales to the description of this issue so we can weight on if this is truly worth while.

One added benefit I see is:

  • It seems that it would be easier to load translations from the config direction than from the source directory

can you provide the added benefits of moving this to config/locales to the description of this issue so we can weight on if this is truly worth while.

I just realize this issue is not that important. I mean, src/locales is ok :sweat_smile:

It seems that it would be easier to load translations from the config direction than from the source directory

Well, I think is the same, also any dev can setup the locales folder by modifying settings.load_path += ["./src/locales"] on config/initializers/i18n.cr

This is just an structure suggestion, maybe we should keep the current setup, WDYT?

It was originally @eliasjpr's suggestion that we put it in src/locale.

BTW, also seems you suggested the src/locales folder :wink:

Ref: https://github.com/amberframework/amber/pull/814#issuecomment-392279691

@faustinoaq Coming from Rails 5.2, I would recommend that every folder within src should be loaded by default because it would be odd and this functionality would have to be documented in Amber docs. Then developers will try to work around this by adding unrelated sources to auto-loaded folders (i.e. models, controller, or others) to reduce the maintinenance. One solution requires two edits versus one. Just something to consider as one works out the design.

Which brings up an new question? Is it possible to create umbrella like applications similar to Phoenix/Elixir? For example, I would ideally would like to structure my applications as follows:

In Elixir, one would use the following structure:

https://elixirschool.com/en/lessons/advanced/umbrella-projects

In Rails, one can do the Rails Engines bit but I prefer the Elixir approach here where everything for that application resides under the specific app's folder. Just thinking out loud here.

@conradwt Yeah I also have seen that on Django (apps), I think Amber doesn't support unbrella projects yet :sweat_smile:

@conradwt I believe the src/locales gets loaded by default since is required by the src/{app}.cr file, I haven't confirm but I almost certain.

Also I'm :100: with you about the apps being all self-contained in the src directory. We have an open issue about how to support modular apps #277 feel free to contribute to any ideas you have.

We have an open issue about how to support modular apps #277 feel free to contribute to any ideas you have.

@eliasjpr Maybe we can follow @damianham approach on this, WDYT?, see: Modular recipe (BTW, I don't think we should use a recipe, but consider a modular structure like this)

See: Why we should use external repos, instead of a monolithic repository

@eliasjpr Maybe we can follow @damianham approach on this, WDYT?, see: Modular recipe (BTW, I don't think we should use a recipe, but consider a modular structure like this)

This is out of scope. Amber strictly follow MVC the way rails does it if someone would like to structure their apps like the modular example you presented that is fine, but it is not part of the conventions Amber has set for the apps.

On another note, I do believe we should add support for a modular approach to mount another app like plugins. For now, I think this is not a big issue having the locales in the src directory.

Maybe this can be closed?

@eliasjpr I believe this can be closed because I'm sure that there are other things which have greater priority and will provide better value to the developer. If this needs to be reopened, then there will be a record of this initial conversation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aarongodin picture aarongodin  路  7Comments

Meldanor picture Meldanor  路  4Comments

ZeroPointEnergy picture ZeroPointEnergy  路  4Comments

faustinoaq picture faustinoaq  路  6Comments

faustinoaq picture faustinoaq  路  4Comments