Skip to content

Commit

Permalink
Выполнен полный перевод приложения на русский язык
Browse files Browse the repository at this point in the history
  • Loading branch information
llMaximll committed Jan 15, 2022
1 parent 0206e10 commit 12115e9
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package com.github.llmaximll.todoapp.data.tasks.local

enum class Categories(val value: String) {
BUSINESS("Business"),
PERSONAL("Personal"),
EDUCATION("Education"),
SCIENCE("Science");
import android.content.Context
import androidx.annotation.StringRes
import com.github.llmaximll.todoapp.R

enum class Categories(@StringRes val value: Int) {
BUSINESS(R.string.details_fragment_category_business),
PERSONAL(R.string.details_fragment_category_personal),
EDUCATION(R.string.details_fragment_category_education),
SCIENCE(R.string.details_fragment_category_science);

companion object {
fun String.toCategory(): Categories =
fun String.toCategory(context: Context): Categories =
when (this) {
BUSINESS.value -> BUSINESS
PERSONAL.value -> PERSONAL
EDUCATION.value -> EDUCATION
context.getString(BUSINESS.value) -> BUSINESS
context.getString(PERSONAL.value) -> PERSONAL
context.getString(EDUCATION.value) -> EDUCATION
else -> SCIENCE
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AddFragment : Fragment() {
viewModel.add(
title = binding.titleEditText.text.toString(),
description = binding.descriptionEditText.text.toString(),
category = binding.textField.text.toString().toCategory()
category = binding.textField.text.toString().toCategory(requireContext())
)
}
}
Expand Down Expand Up @@ -116,13 +116,13 @@ class AddFragment : Fragment() {

private fun setupViews() {
val items = listOf(
Categories.PERSONAL.value,
Categories.BUSINESS.value,
Categories.EDUCATION.value,
Categories.SCIENCE.value,
getString(Categories.PERSONAL.value),
getString(Categories.BUSINESS.value),
getString(Categories.EDUCATION.value),
getString(Categories.SCIENCE.value),
)
val adapter = ArrayAdapter(requireContext(), R.layout.dropdown_item, items)
binding.textField.setText(Categories.PERSONAL.value, false)
binding.textField.setText(getString(Categories.PERSONAL.value), false)
(binding.textField as? AutoCompleteTextView)?.setAdapter(adapter)

val dateString = DateFormat.format("dd/MM/yyyy HH:mm", Date(viewModel.date.timeInMillis))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class DetailsFragment : Fragment() {
private val args: DetailsFragmentArgs by navArgs()
private val categoriesAdapter by lazy(LazyThreadSafetyMode.NONE) {
val items = listOf(
Categories.PERSONAL.value, Categories.BUSINESS.value,
Categories.EDUCATION.value, Categories.SCIENCE.value)
getString(Categories.PERSONAL.value), getString(Categories.BUSINESS.value),
getString(Categories.EDUCATION.value), getString(Categories.SCIENCE.value))
ArrayAdapter(requireContext(), R.layout.dropdown_item, items)
}
private var shouldInterceptBackPress = true
Expand Down Expand Up @@ -118,7 +118,7 @@ class DetailsFragment : Fragment() {

binding.titleEditText.setText(state.task.title.value)
binding.descriptionEditText.setText(state.task.description.value)
binding.textField.setText(state.task.category.value, false)
binding.textField.setText(getString(state.task.category.value), false)
(binding.textField as? AutoCompleteTextView)?.setAdapter(categoriesAdapter)

val dateString = DateFormat.format("dd/MM/yyyy HH:mm", Date(viewModel.date.timeInMillis))
Expand Down Expand Up @@ -238,7 +238,7 @@ class DetailsFragment : Fragment() {
viewModel.update(
title = binding.titleEditText.text.toString(),
description = binding.descriptionEditText.text.toString(),
category = binding.textField.text.toString().toCategory(),
category = binding.textField.text.toString().toCategory(requireContext()),
)
}
}
Expand Down
92 changes: 92 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<resources>
<string name="app_name">ToDoApp</string>
<string name="action_search">Поиск</string>
<string name="action_notifications">Уведомления</string>
<string name="placeholder_in_development">В разработке</string>
<string name="explore_fragment_all_tasks">Все задачи</string>
<string name="explore_fragment_overdue_tasks">Просроченные</string>
<string name="explore_fragment_task_deleted">Задача удалена</string>
<string name="explore_fragment_task_undo">Отменить</string>
<string name="explore_fragment_filter_date">Дата</string>
<string name="explore_fragment_toolbar_title">Задачи</string>
<string name="add_fragment_enter_title">Введите название</string>
<string name="add_fragment_enter_description">Введите описание</string>
<string name="add_fragment_new_task">Новая задача</string>
<string name="add_fragment_today">Сегодня</string>
<string name="add_fragment_error_title_empty">Название не может быть пустым</string>
<string name="add_fragment_error_title_not_unique">Название должно быть уникальным</string>
<string name="add_fragment_creating_task">Создание задачи</string>
<string name="add_fragment_error_description">Описание не может быть пустым</string>
<string name="add_fragment_error_db">Не удалось добавить запись</string>
<string name="add_fragment_date_specify">Уточните дату</string>
<string name="add_fragment_date_picker_title">Выберите дату</string>
<string name="add_fragment_time_picker_title">Выберите время</string>
<string name="add_fragment_error_invalid_date">Неправильная дата</string>
<string name="search_fragment_nothing_found">Не найдено</string>
<string name="search_fragment_error_search">Ошибка поиска</string>
<string name="search_fragment_enter_something">Введите что-нибудь</string>
<string name="details_fragment_error_task_loading">Ошибка загрузки задачи</string>
<string name="details_fragment_task">Задача</string>
<string name="details_fragment_dialog_title">Не удалось сохранить задачу</string>
<string name="details_fragment_dialog_message">Выйти без сохранения?</string>
<string name="details_fragment_dialog_button_negative">Остаться</string>
<string name="details_fragment_dialog_button_positive">Выйти без сохранения</string>
<string name="details_fragment_error_db">Не удалось перезаписать</string>
<string name="details_fragment_menu_delete">Удалить задачу</string>
<string name="details_fragment_dialog_delete_title">Удаление задачи</string>
<string name="details_fragment_dialog_delete_message">После удаления восстановить задачу будет невозможно. Удалить задачу?</string>
<string name="details_fragment_dialog_delete_negative_button">Не удалять</string>
<string name="details_fragment_dialog_delete_positive_button">Удалить задачу</string>
<string name="details_fragment_error_delete">Не удалось удалить задачу</string>
<string name="details_fragment_button_done">Отметить завершенной</string>
<string name="details_fragment_button_not_done">Отметить не завершенной</string>
<string name="details_fragment_category_personal">Личное</string>
<string name="details_fragment_category_business">Бизнес</string>
<string name="details_fragment_category_education">Образование</string>
<string name="details_fragment_category_science">Наука</string>
<string name="shared_element">sharedElement_</string>
<string name="notification_title">ToDoApp</string>
<!-- Strings used for fragments for navigation -->
<string name="explore_fragment_label">Explore Fragment</string>
<string name="search_fragment_label">Search Fragment</string>
<string name="notifications_fragment_label">Notifications Fragment</string>

<string name="lorem_ipsum">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam in scelerisque sem. Mauris
volutpat, dolor id interdum ullamcorper, risus dolor egestas lectus, sit amet mattis purus
dui nec risus. Maecenas non sodales nisi, vel dictum dolor. Class aptent taciti sociosqu ad
litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse blandit eleifend
diam, vel rutrum tellus vulputate quis. Aliquam eget libero aliquet, imperdiet nisl a,
ornare ex. Sed rhoncus est ut libero porta lobortis. Fusce in dictum tellus.\n\n
Suspendisse interdum ornare ante. Aliquam nec cursus lorem. Morbi id magna felis. Vivamus
egestas, est a condimentum egestas, turpis nisl iaculis ipsum, in dictum tellus dolor sed
neque. Morbi tellus erat, dapibus ut sem a, iaculis tincidunt dui. Interdum et malesuada
fames ac ante ipsum primis in faucibus. Curabitur et eros porttitor, ultricies urna vitae,
molestie nibh. Phasellus at commodo eros, non aliquet metus. Sed maximus nisl nec dolor
bibendum, vel congue leo egestas.\n\n
Sed interdum tortor nibh, in sagittis risus mollis quis. Curabitur mi odio, condimentum sit
amet auctor at, mollis non turpis. Nullam pretium libero vestibulum, finibus orci vel,
molestie quam. Fusce blandit tincidunt nulla, quis sollicitudin libero facilisis et. Integer
interdum nunc ligula, et fermentum metus hendrerit id. Vestibulum lectus felis, dictum at
lacinia sit amet, tristique id quam. Cras eu consequat dui. Suspendisse sodales nunc ligula,
in lobortis sem porta sed. Integer id ultrices magna, in luctus elit. Sed a pellentesque
est.\n\n
Aenean nunc velit, lacinia sed dolor sed, ultrices viverra nulla. Etiam a venenatis nibh.
Morbi laoreet, tortor sed facilisis varius, nibh orci rhoncus nulla, id elementum leo dui
non lorem. Nam mollis ipsum quis auctor varius. Quisque elementum eu libero sed commodo. In
eros nisl, imperdiet vel imperdiet et, scelerisque a mauris. Pellentesque varius ex nunc,
quis imperdiet eros placerat ac. Duis finibus orci et est auctor tincidunt. Sed non viverra
ipsum. Nunc quis augue egestas, cursus lorem at, molestie sem. Morbi a consectetur ipsum, a
placerat diam. Etiam vulputate dignissim convallis. Integer faucibus mauris sit amet finibus
convallis.\n\n
Phasellus in aliquet mi. Pellentesque habitant morbi tristique senectus et netus et
malesuada fames ac turpis egestas. In volutpat arcu ut felis sagittis, in finibus massa
gravida. Pellentesque id tellus orci. Integer dictum, lorem sed efficitur ullamcorper,
libero justo consectetur ipsum, in mollis nisl ex sed nisl. Donec maximus ullamcorper
sodales. Praesent bibendum rhoncus tellus nec feugiat. In a ornare nulla. Donec rhoncus
libero vel nunc consequat, quis tincidunt nisl eleifend. Cras bibendum enim a justo luctus
vestibulum. Fusce dictum libero quis erat maximus, vitae volutpat diam dignissim.
</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<string name="details_fragment_error_delete">Failed to delete the task</string>
<string name="details_fragment_button_done">Mark Completed</string>
<string name="details_fragment_button_not_done">Mark as incomplete</string>
<string name="details_fragment_category_personal">Personal</string>
<string name="details_fragment_category_business">Business</string>
<string name="details_fragment_category_education">Education</string>
<string name="details_fragment_category_science">Science</string>
<string name="shared_element">sharedElement_</string>
<string name="notification_title">ToDoApp</string>
<!-- Strings used for fragments for navigation -->
Expand Down

0 comments on commit 12115e9

Please sign in to comment.