Comments (11)
I like the idea of regex support, since its native in javascript it would keep the library tiny
from next-translate.
I thought about this ๐Ok, let's do it!
from next-translate.
@aralroca not sure. I myself am not super fluent with regexes, same for many people I think.
Glob patterns seem to be like a standard for this kind of configuration.
from next-translate.
Ok @BjoernRave @Hanzo93 . Let's do a list of pros and cons:
Pros/Cons | Globbing | Regex |
---|---|---|
Versatility | ๐Good enough, but regex is much richer. | ๐ You can do far more complicated things with regular expressions. |
Lib size | ๐Requires to implement a glob to regex conversor or to import an external lib... So is adding extra kb to the bundle size. |
๐Is native in JavaScript, so is possible to implement without writing so much code. |
Maintenance | ๐ We will need to maintain that extra code of Glob to Regex conversor. | ๐TC39 is mantaining the RegExp for us. |
Easy to use | ๐Easy to learn and remember, is very simple. | ๐Hard to learn and sometimes can be frustrating. |
Performance | ๐ Similar performance than regex but with an additional step to convert Glob to Regex. | ๐Very similar to glob, but without the additional step. |
Do you want to add any points to the list?
I researched and there are a lot of libraries, like webpack
, jest
, babel
that are using regex in their configurations.
from next-translate.
@aralroca thanks for that comparison. I guess looking at it, Regexes make more sense. It's fine by me if you guys prefer it. Will be a way to improve my Regex game :D
from next-translate.
@aralroca can confirm, that it works, good job :)
from next-translate.
@aralroca when you see my config you will know why :D
from next-translate.
@BjoernRave what do you think if instead of glob patterns, we will support regExp when it exist the prefix rgx:
?
Ex:
{
'rgx:^.*/test/.*/example$': ['namespace'] // /this/test/is/an/example -> true
}
In this case, we can provide more flexibility without bringing extra code. The problem of Glob is that we need to do all the conversions or use an external library. In static websites is not a problem because this code is only for the CLI, but in the case of appWithI18n
is going to increase the size of that package.
from next-translate.
@BjoernRave can you confirm that with the new 0.9.0
release is working well in your project?
Your example:
{
"*/new": ["forms"],
"*/[id]/edit": ["forms"]
}
Should be:
{
"rgx:/new$": ["forms"],
"rgx:/\\[id\\]/edit$": ["forms"]
}
or with both rules:
{
"rgx:(/new|/\\[id\\]/edit)$": ["forms"],
}
from next-translate.
@aralroca when I install latest
I only get 0.8.0
from next-translate.
@BjoernRave you are right, I forgot to publish to npm, now is ready https://www.npmjs.com/package/next-translate?activeTab=versions
from next-translate.
Related Issues (20)
- Split out useTranslationAppDir from the useTranslation hook into its own exported regular function HOT 3
- AppDirI18nProvider is not loaded after refresh, so lang is null HOT 2
- Error: Text content does not match server-rendered HTML. HOT 6
- app.listen(port, () => { ^ ReferenceError: app is not defined HOT 1
- next-translate-plugin breaks SSG in app router HOT 7
- App Router - Default locale without it's name on url HOT 2
- TypeError: Cannot read properties of undefined (reading 'loadLocaleFrom') HOT 1
- Locale slug is added to api and other routes outside of app dir
- AppDirI18nProvider is not loaded after refresh, so lang is null HOT 2
- Change language without modifying the URL (/[lang]/rest) HOT 4
- add Dependabot HOT 1
- Next.js app build fails due to empty lang value HOT 3
- change "Twitter" shields badge to "๐ " in README.md
- 404 error pages with next 14 HOT 20
- Localizations not working in prod bundle on NextJs 14 HOT 1
- Buildng project using only app router HOT 9
- Translation not working on client component inside layout HOT 8
- Warning: Detected multiple renderers concurrently rendering the same context provider.
- 404 when accssing homepage HOT 7
- 404 on root when using baseURL in vercel HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-translate.