Git Product home page Git Product logo

nb-trans's People

Contributors

bigbear713 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nb-trans's Issues

Can use the lodash's template() function to handle the translated string

version: v16.0.0
The lib support the template with params, like This is a {{param1}}, and the {{param1}} with be replaced as param value.

Now it is handled by RegExp, it is ok now, but it's a bit complicated. I think we can simplify the process, using a third-party lib to do it.

The lodash you know is a powful third-party lib, and provide template() to handle template string. I think we can try to use it to help us to handle the translated string, we only need to provide the translated string and params value. It can make the process be more simple.

Of course, it's not always the best way, so try it and discuss it

Can use Symbol replace the uuid lib?

version: v15.1.0

We know in translated statement, if a prev param value contains the next param key, there is a problem when using the prev param value to replace the corresponding param key.

// translated statement
const transStr = 'this is {{p1}}, this is {{p2}}';

// param value
const params={
   p1:'{{p2}}',
  p2:'param value 2',
};

// replace param key '{{p1}}' as param value '{{p2}}'
const transStrTmp = 'this is {{p2}}, this is {{p2}}';

// replace param key '{{p2}}' as param value 'param value 2'
const wrongResult = 'this is param value 2, this is param value 2';

// what we want
const rightResult = 'this is {{p2}}, this is param value 2';

So now using uuid to replace all param key in translated statement firstly, then using param values to replace the param keys corresponding uuid value in statement.
But so we have to import uuid lib. I think it is better if here can use Symbol to replace uuid, because the uuid lib can give us unique values, and the Symbol also can be unique

Upgrade to v17

version: v16.0.0

The Angular v17 will be released soon, so the lib is going to be upgraded to v17.0.0 which based on Angular 16

Add function comment in NbTransService

I think it is better when there are some comment about function in NbTransService. So we can know what the function will do easier and not need to view the document

Upgrade to v16

version: v15.1.0

The Angular v16 will be released soon, so the lib is going to be upgraded to v16.0.0 which based on Angular 16

Support the format: {{ param1 }}

version: v15.1.0

Now it is only support the format: {{param1}}, the param key and {{}} can't have spaces between them, it is inconvenient.

It is better if it can support the format: {{ param1 }}, the param key and {{}} can have spaces between them.

Rename the name of some enums, constants

version: 15.0.0
I think the names of NbTransLangEnum, NB_TRANS_MAX_RETRY_TOKEN and NbTransSentenceItemEnum are not good, so I will rename them in the v15.0.0.
The "Enum" is redundant in NbTransLangEnum and NbTransSentenceItemEnum, so I will remove it;
NB_TRANS_MAX_RETRY_TOKEN does not meet rules, the "_TOKEN" will be removed

Will get object data when the trans key is incomplete

version: v15.1.0

When the key value is incomplete, the translated result is an object data, not a string data. Like this:
In translations.json

{
  "level1":{
      "level2":{
          "level3":"hello world"
      }
  }
}

In template:

<div>{{'level1.level2'|nbTrans}}</div>

Then the content in page is

<div>[object Object]</div>

Because the trans key is level1.level2 which is incomplete, so the result is object data: { "level3":"hello world" }
The complete key is level1.level2.level3,and the expected result is hello world

Provide a new nb-trans component to render complex content

version: v15.2.0

Now when we want to render a complex content, we can use <nb-trans></nb-trans> component. By there will always have a nb-trans tag, it is not good in some scenarios, such as setting style via html tag. So I hope the nb-trans tag can be non-existent when I need.

Update the link in documents

The default branch has been renamed as 'main', but the link containing old branch name (master) has not been updated in documents.

So let's update them as new default branch name

Update document

Update readme markdown and change log markdown documents.

Remove errors and add some links

The version of nb-common is error

Version: v13.0.0

Description: The version of @bigbear713/nb-common is ^12.1.0 in package.json, but it is base on ng13, so here is invalid

In trans component, the trans result is wrong in some case

** version **: v15.1.0

When the translation string and options like this:

// translation.json
{
   "sentence": "This is {{p1}} and {{p2}}"
}

const options={
    params:{
        "p1":"{{p2}}",
        "p2": '123'
    }
};

The expected result is: This is {{p2}} and 123, and the trans result is right when using nbTrans pipe.
But It is wrong when using component and the wrong result is: This is 123 and 123

Add Eslint and Prettier to the project

As we all know the Eslint and prettier are useful when we working with others, but now it is missing for the project. So let's add the Eslint and Prettier to the project

Support to import the components as standalone mode

version: v15.0.0

Now the components can be used in standalone components, but should import the NbTransModule first, someone may think using module is not good in standalone component, it is better when the import is all components, although it has no effect on the size of the packed file.
And I think it is ok to import the components as standalone mode, so I will support it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.