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

feat: New Localization module #302

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
17b090d
Implement Lang facade
kkumar-gcc Sep 22, 2023
4ffcccb
add IsLocale method
kkumar-gcc Sep 23, 2023
1b165b7
add pluralization support
kkumar-gcc Sep 23, 2023
64ec838
remove context from translator methods
kkumar-gcc Sep 25, 2023
00b7003
add fallback loading of translations
kkumar-gcc Sep 26, 2023
cdcc73b
define a custom type for context key
kkumar-gcc Sep 26, 2023
541019b
set locale in http context
kkumar-gcc Oct 2, 2023
c77479b
Merge branch 'master' into kkumar-gcc/#39
kkumar-gcc Oct 3, 2023
f9d300e
fix: #267 (#306)
devhaozi Oct 3, 2023
482145a
add tests for file loader
kkumar-gcc Oct 4, 2023
72e221e
refactor: move mocks (#307)
devhaozi Oct 5, 2023
4a6e705
build(deps): bump the go-modules group with 1 update (#310)
dependabot[bot] Oct 6, 2023
b1c0268
build(deps): bump the github-actions group with 1 update (#312)
dependabot[bot] Oct 7, 2023
2ecb709
build(deps): bump the go-modules group with 1 update (#313)
dependabot[bot] Oct 7, 2023
1fe58aa
build(deps): bump the go-modules group with 2 updates (#315)
dependabot[bot] Oct 10, 2023
be95246
build(deps): bump github.com/brianvoe/gofakeit/v6 from 6.23.2 to 6.24…
dependabot[bot] Oct 24, 2023
c425f44
build(deps): bump the go-modules group with 6 updates (#326)
dependabot[bot] Oct 26, 2023
74cc654
build(deps): bump the go-modules group with 1 update (#327)
dependabot[bot] Oct 27, 2023
81cd827
build(deps): bump github.com/golang-module/carbon/v2 (#331)
dependabot[bot] Nov 3, 2023
7bfd957
chore: merge v1.13.x to master (#333)
devhaozi Nov 4, 2023
0a38081
Merge v1.13.4 (#345)
hwbrzzl Nov 9, 2023
376f1d9
fix: Validator Bind can't cast value (#336)
devhaozi Nov 10, 2023
6b10569
build(deps): bump the go-modules group with 3 updates (#346)
dependabot[bot] Nov 13, 2023
b3de65f
feat: [#289] Remove github.com/ory/dockertest (#334)
hwbrzzl Nov 15, 2023
7a269f7
remove `maps.Copy` function
kkumar-gcc Nov 15, 2023
09d4514
build(deps): bump the github-actions group with 1 update (#348)
dependabot[bot] Nov 16, 2023
c1af159
build(deps): bump the go-modules group with 1 update (#347)
dependabot[bot] Nov 16, 2023
0f69215
support empty string and new lines in a message for translation
kkumar-gcc Nov 16, 2023
b895b87
add tests for message selector
kkumar-gcc Nov 16, 2023
df11554
finish tests for `MessageSelector`
kkumar-gcc Nov 16, 2023
c7473b3
add test cases for 'Get' method in translator
kkumar-gcc Nov 16, 2023
8722588
Implement Lang facade
kkumar-gcc Sep 22, 2023
6d2c301
add IsLocale method
kkumar-gcc Sep 23, 2023
a384ec5
add pluralization support
kkumar-gcc Sep 23, 2023
2f9cae1
remove context from translator methods
kkumar-gcc Sep 25, 2023
b2dacc6
add fallback loading of translations
kkumar-gcc Sep 26, 2023
620c8f6
define a custom type for context key
kkumar-gcc Sep 26, 2023
5b4aaf4
set locale in http context
kkumar-gcc Oct 2, 2023
114bd36
add tests for file loader
kkumar-gcc Oct 4, 2023
3abc8ac
remove `maps.Copy` function
kkumar-gcc Nov 15, 2023
ea59475
support empty string and new lines in a message for translation
kkumar-gcc Nov 16, 2023
73de8c6
add tests for message selector
kkumar-gcc Nov 16, 2023
402d1a7
finish tests for `MessageSelector`
kkumar-gcc Nov 16, 2023
3f9f66a
add test cases for 'Get' method in translator
kkumar-gcc Nov 16, 2023
a47d468
resolve conflict between master and current branch
kkumar-gcc Nov 16, 2023
97bb8e2
Merge remote-tracking branch 'origin/kkumar-gcc/#39' into kkumar-gcc/#39
kkumar-gcc Nov 16, 2023
72f7ff2
chore: update mocks
kkumar-gcc Nov 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions contracts/foundation/application.go
kkumar-gcc marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package foundation

import (
"context"

"github.com/goravel/framework/contracts/console"
"github.com/goravel/framework/contracts/http"
)

//go:generate mockery --name=Application
Expand All @@ -25,4 +28,14 @@ type Application interface {
PublicPath(path string) string
// Publishes register the given paths to be published by the "vendor:publish" command.
Publishes(packageName string, paths map[string]string, groups ...string)
// GetLocale get the current application locale.
GetLocale(ctx context.Context) string
// SetLocale set the current application locale.
SetLocale(ctx context.Context, locale string) context.Context
// SetLocaleByHttp set the current application/context locale by http request.
SetLocaleByHttp(ctx http.Context, locale string)
// Version gets the version number of the application.
Version() string
// IsLocale get the current application locale.
IsLocale(ctx http.Context, locale string) bool
kkumar-gcc marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 5 additions & 0 deletions contracts/foundation/container.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package foundation

import (
"context"

"github.com/goravel/framework/contracts/auth"
"github.com/goravel/framework/contracts/auth/access"
"github.com/goravel/framework/contracts/cache"
Expand All @@ -20,6 +22,7 @@ import (
"github.com/goravel/framework/contracts/route"
"github.com/goravel/framework/contracts/schedule"
"github.com/goravel/framework/contracts/testing"
"github.com/goravel/framework/contracts/translation"
"github.com/goravel/framework/contracts/validation"
)

Expand Down Expand Up @@ -50,6 +53,8 @@ type Container interface {
MakeGrpc() grpc.Grpc
// MakeHash resolves the hash instance.
MakeHash() hash.Hash
// MakeLang resolves the lang instance.
MakeLang(ctx context.Context) translation.Translator
// MakeLog resolves the log instance.
MakeLog() log.Log
// MakeMail resolves the mail instance.
Expand Down
102 changes: 95 additions & 7 deletions contracts/foundation/mocks/Application.go
kkumar-gcc marked this conversation as resolved.
Show resolved Hide resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions contracts/translation/loader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package translation

//go:generate mockery --name=Loader
type Loader interface {
// Load the messages for the given locale.
Load(folder string, locale string) (map[string]map[string]string, error)
}
50 changes: 50 additions & 0 deletions contracts/translation/mocks/Loader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading