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

Add aah generate i18n command to generate i18n vars #119

Open
julienkosinski opened this issue Sep 16, 2017 · 7 comments
Open

Add aah generate i18n command to generate i18n vars #119

julienkosinski opened this issue Sep 16, 2017 · 7 comments
Assignees
Labels
Projects

Comments

@julienkosinski
Copy link

julienkosinski commented Sep 16, 2017

Hello,

Besides aah generate which could be used for whole generation about MVC (model needs database layer) I would like to present a functionality that I thought about i18n. The idea is to be able to generate a messages file like below in this example:

For i18n, if I have i18n . "page.site.title.index" in a view (so that's for each i18n vars defined in view) , I will write in CLI aah generate i18n fr, then it will generate a messages.fr file with:

page {
  site {
    title {
      index = ""
    }
  }
}

We already talked about that @jeevatkm in gitter, that's why it's already in roadmap. This issue is intended to precise it :).

Thank you very much! :D

@jeevatkm jeevatkm self-assigned this Sep 16, 2017
@jeevatkm jeevatkm added cli-tool aah CLI tool feature labels Sep 16, 2017
@jeevatkm jeevatkm added this to Backlog in aah Roadmap Sep 17, 2017
@jeevatkm jeevatkm moved this from Backlog to v0.10 - Iteration (Not yet started) in aah Roadmap Oct 7, 2017
@jeevatkm jeevatkm moved this from v0.10 - Iteration (Not yet started) to Backlog in aah Roadmap Oct 7, 2017
@adelowo
Copy link
Contributor

adelowo commented Apr 12, 2018

Wait, this would potentially scan through the entire codebase to determine the vars ? or how is this supposed to work ?

@jeevatkm
Copy link
Member

jeevatkm commented Apr 12, 2018

@adelowo Thanks for asking.

This is an idea. As you know localizing application is considerable effort, aah CLI is gonna help on that. So command creates i18n placeholder then aah user fills in the locale based values in it.

Let's move on to implementation part:

Command: `aah generate i18n --importpath github.com/user/app --locale "en-US, fr, de-DE"` 
Alias:` aah g i -i <value> -l <value>`

--importpath is optional if run from app directory tree
--locale creates `messages.{provided-locale}` file, if not provided then only creates the `messages.keys` 

Steps:

  • Command scans views directory and its sub-directories view files, uses the config from section view { ... } such as file extension, delimiter, etc.
  • Looks for pattern {{ i18n . "key" }} - possible Regex would help us here
  • Writes the messages.keys file into directory app-base-dir/i18n

Sample messages.keys content:

# PLEASE DO NOT EDIT
# It will be overwritten on next run
page {
  site {
    title {
      index = "page.site.title.index"
    }
  }
}

Please let me know your thoughts.

@adelowo
Copy link
Contributor

adelowo commented Apr 12, 2018

Understood.... I am just more worried about updates. Does this plan to support update operations like running the command again after making some changes to the views - even though it was previously generated ?

@jeevatkm
Copy link
Member

jeevatkm commented Apr 12, 2018

@adelowo That's a good question and concern.

Yes, user can run n no. of times. messages.keys file would be overwritten on every run, since its one way. However locale message file would be appended with new keys.

BTW, Currently aahframework.org/config.v0 doesn't have persistence support yet. So before this implementation we have to added file persistence support for config values.

Would you like to try on it?

  • Config file persistence support
  • Command aah generate i18n

@adelowo
Copy link
Contributor

adelowo commented Apr 13, 2018

I would take a stab at it next week if it has not been worked on

@jeevatkm
Copy link
Member

@adelowo I'm glad to hear that, No I'm not working on it. I have shared my idea with you today.

Currently I'm doing my homework on Websocket and Configurable roles/permissions for each route definition.

@jeevatkm
Copy link
Member

This depends on #231

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

No branches or pull requests

3 participants