jsverse / transloco-keys-manager

🦄 The Key to a Better Translation Experience
https://github.com/jsverse/transloco/
MIT License
199 stars 49 forks source link

Feature: Provide a way to override sourceRoot #148

Closed penleychan closed 1 year ago

penleychan commented 1 year ago

Is there an existing issue for this?

Is your feature request related to a problem? Please describe

Currently the default source root src if no workspace/angular.json is found.

Project was generated with nx with Integrated Repos workspace, and default source root is apps.

Describe the solution you'd like

Provide a configuration to override sourceRoot via options on transloco.config.js.

{
   ....
   sourceRoot: 'apps',
   ....
}

Describe alternatives you've considered

No response

Describe alternatives you've considered

N/A

Describe alternatives you've considered

N/A

Additional context

No response

I would like to make a pull request for this feature

No

JelleBruisten commented 1 year ago

This could also provide workaround for the bug #149 since when we call transloco-keys-manager extract --sourceRoot /libs/my-library it won't need to find a angular.json to figure out the sourceRoot. If they would also allow sourceRoot to be set from cli

penleychan commented 1 year ago

No idea when this feature ever going to be implement or if ever, I've quickly created a patch for my own use case. @JelleBruisten, no idea if this will work for you or not don't have time to invest in it. Published on npmjs:

https://www.npmjs.com/package/@penleychan/transloco-keys-manager

yarn add @penleychan/transloco-keys-manager

Provide sourceRoot on transloco.config.js:

keysManager: {
    ...
    sourceRoot: 'apps'
  },

Or via cli transloco-keys-manager extract --project PROJECTNAME --sourceRoot apps

Basically all I did was commented out that error message, it will still default to src then on resolveConfig.ts If there's sourceRoot detected from cli or config.js it will override the projectBasePath.

If nothing is found it will display Input path provided doesn't exists!

shaharkazaz commented 1 year ago

I've added support for workspaces without root configurations, please note that you must pass the project name in order for the commands to work since it can't resolve the default project without a root config. Pleas try v3.6 and LMK.

penleychan commented 1 year ago

Thanks for adding this.

1 Issue:

  1. Extract seems to only look within the apps/[projectname]/src/app directory, anything outside of that directory does not get scanned ex. apps/[projectname]/src/components. But this can be resolved by providing input value to ./

Regards

shaharkazaz commented 1 year ago

@penleychan As you said, it's not an issue since it's configurable 🙂 Closing this as the main issue is resolved.