mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 20:15:50 +08:00
7adf71a203
* Pluralize `discourse_narrative_bot.dice.not_enough_dice` The number of dice requires a pluralized string. Fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/278/en-ar#51346 * Always use "two-factor" instead of "second factor" or "two factor" Using different terms for the same thing is quite confusing. Fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-nl#40096 * Remove whitespace before ellipsis for consistency Fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-nl#53978 * Remove unused strings from locale file * Correct grammar in `site_settings.review_media_unless_trust_level` Fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/248/en-nl#54018 * Correct grammar in `reviewables.reasons.contains_media` Fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/248/en-nl#54020 * Correct grammar in user notifications It also adds a link to the /about page in order to give the user a clue who the site admins are. This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/248/en-nl#54084 * Use "log in" instead of "login" when it's a verb This fixes multiple issues: * https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-nl#40940 * https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/248/en-nl#47858 * https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/248/en-nl#49458 * Replace "Github" with "GitHub" * Remove "discourse.org" from title of 503 error page * Replace weirdly formatted multi line string * Pluralize `js.composer.group_mentioned_limit` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#41158 * Remove unused string and pluralize `js.topic.feature_topic.confirm_pin_globally` This kinda fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#42114 as `js.topic.feature_topic.confirm_pin` wasn't used anymore. * Pluralize `js.user.second_factor_backup.remaining_codes` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#40054 * Pluralize `js.composer.error.tags_missing` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#41184 * Pluralize `js.post.errors.too_many_dragged_and_dropped_files` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#42408 * Remove unused `js.posts_long` and `js.likes_long` This fixes the following issues in an unexpected way: * https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#42974 * https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#42994 * Pluralize `js.bootstrap_mode_enabled` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#38726 * Remove unused `long_form` from `post_action_types` This more or less fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/248/en-ar#47158 * Pluralize `js.presence.replying` and `js.presence.replying` This fixes the following issues: * https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/282/en-ar#51588 * https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/282/en-ar#51590 * Pluralize `js.user.second_factor_backup.manage` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#40044 * Stop using concatenated strings for "Recently Used Devices" This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#40308 * Pluralize `js.category_row.topic_count` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#41056 * Pluralize `js.select_kit.invalid_selection_length` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#41072 * Pluralize `js.notifications.membership_request_consolidated` This fixes https://discourse.crowdin.com/translate/f3230e7607a36bb0a2f97fd90605a44e/246/en-ar#41416
33 lines
909 B
Ruby
33 lines
909 B
Ruby
# frozen_string_literal: true
|
|
|
|
module DiscourseNarrativeBot
|
|
class Dice
|
|
MAXIMUM_NUM_OF_DICE = 20
|
|
MAXIMUM_RANGE_OF_DICE = 120
|
|
|
|
def self.roll(num_of_dice, range_of_dice)
|
|
if num_of_dice == 0 || range_of_dice == 0
|
|
return I18n.t('discourse_narrative_bot.dice.invalid')
|
|
end
|
|
|
|
output = +''
|
|
|
|
if num_of_dice > MAXIMUM_NUM_OF_DICE
|
|
output << I18n.t('discourse_narrative_bot.dice.not_enough_dice', count: MAXIMUM_NUM_OF_DICE)
|
|
output << "\n\n"
|
|
num_of_dice = MAXIMUM_NUM_OF_DICE
|
|
end
|
|
|
|
if range_of_dice > MAXIMUM_RANGE_OF_DICE
|
|
output << I18n.t('discourse_narrative_bot.dice.out_of_range')
|
|
output << "\n\n"
|
|
range_of_dice = MAXIMUM_RANGE_OF_DICE
|
|
end
|
|
|
|
output << I18n.t('discourse_narrative_bot.dice.results',
|
|
results: num_of_dice.times.map { rand(1..range_of_dice) }.join(", ")
|
|
)
|
|
end
|
|
end
|
|
end
|