Skip to content

Commit

Permalink
fix: change locale logic
Browse files Browse the repository at this point in the history
`#` set default `en`
  • Loading branch information
laigasus committed Apr 28, 2024
1 parent cec3baf commit a7190ef
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 88 deletions.
70 changes: 35 additions & 35 deletions app/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
!base/header.html
base.header.logo=\uBD84\uB9AC\u3145\u3131
base.header.nav.dictionary.text=\uC0AC\uC804
base.header.nav.dictionary.title=\uBD84\uB9AC\uBC30\uCD9C \uC0AC\uC804\uC785\uB2C8\uB2E4
base.header.nav.community.text=\uCEE4\uBBA4\uB2C8\uD2F0
base.header.nav.community.title=\uCEE4\uBBA4\uB2C8\uD2F0\uC785\uB2C8\uB2E4
base.header.nav.login.text=\uB85C\uADF8\uC778
base.header.nav.login.title=\uB85C\uADF8\uC778\uD558\uC5EC \uCEE4\uBBA4\uB2C8\uD2F0, \uB3C4\uAC10\uC744 \uC774\uC6A9\uD558\uC138\uC694
base.header.nav.profile.member=\uD504\uB85C\uD544
base.header.nav.profile.logout=\uB85C\uADF8\uC544\uC6C3
base.header.nav.theme.light.text=\uB77C\uC774\uD2B8
base.header.nav.theme.dark.text=\uB2E4\uD06C
base.header.nav.theme.auto.text=\uC790\uB3D9
base.header.logo=BLISGO
base.header.nav.dictionary.text=Dictionary
base.header.nav.dictionary.title=This is the Dictionary
base.header.nav.community.text=Community
base.header.nav.community.title=This is the community
base.header.nav.login.text=Login
base.header.nav.login.title=Login to use the community and bookmark
base.header.nav.profile.member=Profile
base.header.nav.profile.logout=Logout
base.header.nav.theme.light.text=Light
base.header.nav.theme.dark.text=Dark
base.header.nav.theme.auto.text=Auto
!index.html
index.hero.heading=\uBD84\uB9AC\u3145\u3131
index.hero.subheading=\uBD84\uB9AC\uBC30\uCD9C\uC744 \uB354\uC6B1 \uD3B8\uB9AC\uD558\uAC8C!
index.hero.heading=BLISGO
index.hero.subheading=Make separation discharge more convenient!
!community/board.html
community.board.fab.write.title=\uAE00\uC4F0\uAE30
community.board.post.preview.empty=\uBBF8\uB9AC\uBCF4\uAE30\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.
community.board.fab.write.title=Write
community.board.post.preview.empty=There is no preview.
!community/content.html
community.content.fab.comment.title=\uB313\uAE00
community.content.fab.like.title=\uC88B\uC544\uC694
community.content.fab.edit.title=\uD3B8\uC9D1
community.content.fab.delete.title=\uC0AD\uC81C
modal.comment.header.heading=\uB313\uAE00
modal.comment.body.input.placeholder=\uC8FC\uC758! \uC904\uBC14\uAFC8\uC744 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4
community.content.fab.comment.title=Comments
community.content.fab.like.title=Like
community.content.fab.edit.title=Edit
community.content.fab.delete.title=Delete
modal.comment.header.heading=Comments
modal.comment.body.input.placeholder=Caution! Comments are not allowed line breaks
!community/write.html
community.write.heading.input.placeholder=\uC81C\uBAA9
community.write.fab.submit.title=\uB4F1\uB85D
community.write.heading.input.placeholder=Title
community.write.fab.submit.title=Submit
!dictionary/info.html
dictionary.info.alert=\uC774\uB7F0! \uD574\uB2F9 \uAC00\uC774\uB4DC\uC5D0 \uB300\uD574 \uB4F1\uB85D\uB41C \uC815\uBCF4\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. \uBB38\uC758\uD574\uC8FC\uC2DC\uBA74 \uBE60\uB978 \uC2DC\uC77C \uB0B4 \uCD94\uAC00\uD558\uACA0\uC2B5\uB2C8\uB2E4!
dictionary.info.related.heading=\uC5F0\uAD00 \uD3D0\uAE30\uBB3C
dictionary.info.alert=Ouch! The word you are looking for does not exist. Contact us and we'll add them as soon as possible!
dictionary.info.related.heading=Related wastes
!member/profile.html
member.profile.tabs.dogam=\uB3C4\uAC10
member.profile.tabs.dogam=Bookmark
!\uAE30\uD0C0
toast.dogam.create.success=\uB3C4\uAC10\uC5D0 \uCD94\uAC00\uB418\uC5C8\uC2B5\uB2C8\uB2E4
toast.dogam.create.error=\uB3C4\uAC10\uC5D0 \uCD94\uAC00\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4
toast.dogam.delete.success=\uB3C4\uAC10\uC5D0\uC11C \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4
toast.dogam.delete.error=\uB3C4\uAC10\uC5D0\uC11C \uC0AD\uC81C\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4
toast.post.like.success=\uC88B\uC544\uC694\uB97C \uB20C\uB800\uC2B5\uB2C8\uB2E4
toast.post.like.error=\uC88B\uC544\uC694\uB97C \uB204\uB974\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4
toast.post.unlike.success=\uC88B\uC544\uC694\uB97C \uCDE8\uC18C\uD588\uC2B5\uB2C8\uB2E4
toast.post.unlike.error=\uC88B\uC544\uC694\uB97C \uCDE8\uC18C\uD558\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4
toast.dogam.create.success=Added to bookmark
toast.dogam.create.error=Failed to add to bookmark
toast.dogam.delete.success=Removed from bookmark
toast.dogam.delete.error=Failed to remove from bookmark
toast.post.like.success=Liked
toast.post.like.error=Failed to like
toast.post.unlike.success=Unliked
toast.post.unlike.error=Failed to unlike
43 changes: 0 additions & 43 deletions app/src/main/resources/messages_en.properties

This file was deleted.

43 changes: 43 additions & 0 deletions app/src/main/resources/messages_ko.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
!base/header.html
base.header.logo=\uBD84\uB9AC\u3145\u3131
base.header.nav.dictionary.text=\uC0AC\uC804
base.header.nav.dictionary.title=\uBD84\uB9AC\uBC30\uCD9C \uC0AC\uC804\uC785\uB2C8\uB2E4
base.header.nav.community.text=\uCEE4\uBBA4\uB2C8\uD2F0
base.header.nav.community.title=\uCEE4\uBBA4\uB2C8\uD2F0\uC785\uB2C8\uB2E4
base.header.nav.login.text=\uB85C\uADF8\uC778
base.header.nav.login.title=\uB85C\uADF8\uC778\uD558\uC5EC \uCEE4\uBBA4\uB2C8\uD2F0, \uB3C4\uAC10\uC744 \uC774\uC6A9\uD558\uC138\uC694
base.header.nav.profile.member=\uD504\uB85C\uD544
base.header.nav.profile.logout=\uB85C\uADF8\uC544\uC6C3
base.header.nav.theme.light.text=\uB77C\uC774\uD2B8
base.header.nav.theme.dark.text=\uB2E4\uD06C
base.header.nav.theme.auto.text=\uC790\uB3D9
!index.html
index.hero.heading=\uBD84\uB9AC\u3145\u3131
index.hero.subheading=\uBD84\uB9AC\uBC30\uCD9C\uC744 \uB354\uC6B1 \uD3B8\uB9AC\uD558\uAC8C!
!community/board.html
community.board.fab.write.title=\uAE00\uC4F0\uAE30
community.board.post.preview.empty=\uBBF8\uB9AC\uBCF4\uAE30\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.
!community/content.html
community.content.fab.comment.title=\uB313\uAE00
community.content.fab.like.title=\uC88B\uC544\uC694
community.content.fab.edit.title=\uD3B8\uC9D1
community.content.fab.delete.title=\uC0AD\uC81C
modal.comment.header.heading=\uB313\uAE00
modal.comment.body.input.placeholder=\uC8FC\uC758! \uC904\uBC14\uAFC8\uC744 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4
!community/write.html
community.write.heading.input.placeholder=\uC81C\uBAA9
community.write.fab.submit.title=\uB4F1\uB85D
!dictionary/info.html
dictionary.info.alert=\uC774\uB7F0! \uD574\uB2F9 \uAC00\uC774\uB4DC\uC5D0 \uB300\uD574 \uB4F1\uB85D\uB41C \uC815\uBCF4\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4. \uBB38\uC758\uD574\uC8FC\uC2DC\uBA74 \uBE60\uB978 \uC2DC\uC77C \uB0B4 \uCD94\uAC00\uD558\uACA0\uC2B5\uB2C8\uB2E4!
dictionary.info.related.heading=\uC5F0\uAD00 \uD3D0\uAE30\uBB3C
!member/profile.html
member.profile.tabs.dogam=\uB3C4\uAC10
!\uAE30\uD0C0
toast.dogam.create.success=\uB3C4\uAC10\uC5D0 \uCD94\uAC00\uB418\uC5C8\uC2B5\uB2C8\uB2E4
toast.dogam.create.error=\uB3C4\uAC10\uC5D0 \uCD94\uAC00\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4
toast.dogam.delete.success=\uB3C4\uAC10\uC5D0\uC11C \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4
toast.dogam.delete.error=\uB3C4\uAC10\uC5D0\uC11C \uC0AD\uC81C\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4
toast.post.like.success=\uC88B\uC544\uC694\uB97C \uB20C\uB800\uC2B5\uB2C8\uB2E4
toast.post.like.error=\uC88B\uC544\uC694\uB97C \uB204\uB974\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4
toast.post.unlike.success=\uC88B\uC544\uC694\uB97C \uCDE8\uC18C\uD588\uC2B5\uB2C8\uB2E4
toast.post.unlike.error=\uC88B\uC544\uC694\uB97C \uCDE8\uC18C\uD558\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@
@Converter
@RequiredArgsConstructor
public class I18nListConverter implements AttributeConverter<List<String>, String> {
private final JsonParser jsonContentParser;
private final JsonParser jsonParser;

@Override
public String convertToDatabaseColumn(List<String> attributes) {
String language = LocaleContextHolder.getLocale().getLanguage();
Locale locale = List.of(Locale.KOREAN, Locale.ENGLISH)
.contains(LocaleContextHolder.getLocale()) ?
LocaleContextHolder.getLocale() :
Locale.ENGLISH;

if (attributes == null || attributes.isEmpty()) {
return null;
}

return jsonContentParser.toString(Map.of(language, attributes));
return jsonParser.toString(Map.of(locale.getLanguage(), attributes));
}

@Override
Expand All @@ -38,6 +41,6 @@ public List<String> convertToEntityAttribute(final String dbData) {
LocaleContextHolder.getLocale() :
Locale.ENGLISH;

return jsonContentParser.getLocalizedList(dbData, locale);
return jsonParser.getLocalizedList(dbData, locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver;

import java.util.List;
import java.util.Locale;

@Configuration
public class LocaleConfig {
public class LocaleConfig implements WebMvcConfigurer {
@Bean
@Description("클라이언트 요청의 Accept-Language 헤더를 기반으로 Locale을 결정. 값이 없으면 시스템 언어(영어)로 설정")
public LocaleResolver localeResolver() {
AcceptHeaderLocaleResolver sessionLocaleResolver = new AcceptHeaderLocaleResolver();
sessionLocaleResolver.setSupportedLocales(List.of(Locale.ENGLISH, Locale.KOREAN));
sessionLocaleResolver.setDefaultLocale(Locale.KOREAN);
return sessionLocaleResolver;
AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();
localeResolver.setDefaultLocale(Locale.ENGLISH);
Locale.setDefault(Locale.ENGLISH);

return localeResolver;
}
}

0 comments on commit a7190ef

Please sign in to comment.