Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pv168-01-todo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ondřej Hrdlička
pv168-01-todo
Commits
ab6cd79f
There was an error fetching the commit references. Please try again later.
Commit
ab6cd79f
authored
3 years ago
by
Kristyna Fuchsova
Committed by
Ondřej Hrdlička
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Adds Localization class
parent
8ca4d21b
No related branches found
No related tags found
2 merge requests
!52
Final project MR
,
!47
Localization
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/cz/muni/fi/pv168/project/ui/i18n/I18N.java
+29
-0
29 additions, 0 deletions
src/main/java/cz/muni/fi/pv168/project/ui/i18n/I18N.java
with
29 additions
and
0 deletions
src/main/java/cz/muni/fi/pv168/project/ui/i18n/I18N.java
0 → 100644
+
29
−
0
View file @
ab6cd79f
package
cz.muni.fi.pv168.project.ui.i18n
;
import
java.text.MessageFormat
;
import
java.util.ResourceBundle
;
public
final
class
I18N
{
private
final
ResourceBundle
bundle
;
private
final
String
prefix
;
public
I18N
(
Class
<?>
clazz
)
{
var
packagePath
=
clazz
.
getPackageName
().
replace
(
"."
,
"/"
)
+
'/'
;
System
.
out
.
println
(
packagePath
);
bundle
=
ResourceBundle
.
getBundle
(
packagePath
+
"i18n"
);
prefix
=
clazz
.
getSimpleName
()
+
"."
;
}
public
String
getString
(
String
key
)
{
return
bundle
.
getString
(
prefix
+
key
);
}
public
String
getFormattedMessage
(
String
key
,
Object
...
arguments
)
{
return
MessageFormat
.
format
(
getString
(
key
),
arguments
);
}
public
<
E
extends
Enum
<
E
>>
String
getString
(
E
key
)
{
return
bundle
.
getString
(
key
.
getClass
().
getSimpleName
()
+
"."
+
key
.
name
());
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment