intlify / intlify/srvmid

we need a getCookieLocale, getQueryLocale ... without throwing so i can chain logic and make fallbacks

Open
#27 0 comments 0 reactions 0 assignees View on GitHub
feature Hono
Dominant language
TypeScript
Stars
13
Forks
2
Avg merge
4h 14m
Merged PRs (30d)
4

Description

### Clear and concise description of the problem

the getCookieLocal, getQueryLocale, getHeaderLocale always throw if no local found

i want to make a logic that check firstly for the query and then the cookies or the header

how can i achieve that without a long chain of tryandcatch

### Suggested solution

provide an other functions like tryQueryLocale, tryHeaderLocale
that returns null or undefined and don't throw anything

make an option to the current functions to make it throw or not an error

### Alternative

_No response_

### Additional context

_No response_

### Validations

- [X] Follow our [Code of Conduct](https://github.com/intlify/.github/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guide](https://github.com/intlify/utils/blob/main/CONTRIBUTING.md).
- [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.