Merge branch 'master' of https://github.com/glitch-soc/mastodon into glitch-langfiles

# Conflicts:
#	app/javascript/glitch/locales/ja.json
pull/252/head
ncls7615 2017-12-11 09:43:21 +09:00
commit a98b0a47ef
55 changed files with 418 additions and 173 deletions

View File

@ -62,6 +62,7 @@ class ApplicationController < ActionController::Base
pack: pack_name,
preload: nil,
skin: nil,
supported_locales: data['locales'],
}
if data['pack'][pack_name].is_a?(Hash)
pack_data[:common] = nil if data['pack'][pack_name]['use_common'] == false
@ -93,6 +94,7 @@ class ApplicationController < ActionController::Base
pack: nil,
preload: nil,
skin: nil,
supported_locales: data['locales'],
}
end

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/ar.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/bg.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/ca.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/de.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,50 @@
import inherited from 'mastodon/locales/en.json';
const messages = {
'getting_started.open_source_notice': 'Glitchsoc is free open source software forked from {Mastodon}. You can contribute or report issues on GitHub at {github}.',
'layout.auto': 'Auto',
'layout.current_is': 'Your current layout is:',
'layout.desktop': 'Desktop',
'layout.mobile': 'Mobile',
'navigation_bar.app_settings': 'App settings',
'getting_started.onboarding': 'Show me around',
'onboarding.page_one.federation': '{domain} is an \'instance\' of Mastodon. Mastodon is a network of independent servers joining up to make one larger social network. We call these servers instances.',
'onboarding.page_one.welcome': 'Welcome to {domain}!',
'onboarding.page_six.github': '{domain} runs on Glitchsoc. Glitchsoc is a friendly {fork} of {Mastodon}, and is compatible with any Mastodon instance or app. Glitchsoc is entirely free and open-source. You can report bugs, request features, or contribute to the code on {github}.',
'settings.auto_collapse': 'Automatic collapsing',
'settings.auto_collapse_all': 'Everything',
'settings.auto_collapse_lengthy': 'Lengthy toots',
'settings.auto_collapse_media': 'Toots with media',
'settings.auto_collapse_notifications': 'Notifications',
'settings.auto_collapse_reblogs': 'Boosts',
'settings.auto_collapse_replies': 'Replies',
'settings.close': 'Close',
'settings.collapsed_statuses': 'Collapsed toots',
'settings.enable_collapsed': 'Enable collapsed toots',
'settings.general': 'General',
'settings.image_backgrounds': 'Image backgrounds',
'settings.image_backgrounds_media': 'Preview collapsed toot media',
'settings.image_backgrounds_users': 'Give collapsed toots an image background',
'settings.media': 'Media',
'settings.media_letterbox': 'Letterbox media',
'settings.media_fullwidth': 'Full-width media previews',
'settings.preferences': 'User preferences',
'settings.wide_view': 'Wide view (Desktop mode only)',
'settings.navbar_under': 'Navbar at the bottom (Mobile only)',
'status.collapse': 'Collapse',
'status.uncollapse': 'Uncollapse',
'home.column_settings.show_direct': 'Show DMs',
'notification.markForDeletion': 'Mark for deletion',
'notifications.clear': 'Clear all my notifications',
'notifications.marked_clear_confirmation': 'Are you sure you want to permanently clear all selected notifications?',
'notifications.marked_clear': 'Clear selected notifications',
'notification_purge.btn_all': 'Select\nall',
'notification_purge.btn_none': 'Select\nnone',
'notification_purge.btn_invert': 'Invert\nselection',
'notification_purge.btn_apply': 'Clear\nselected',
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/eo.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/es.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/fa.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/fi.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/fr.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/he.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/hr.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/hu.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/id.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/io.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/it.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -1,4 +1,6 @@
{
import inherited from 'mastodon/locales/ja.json';
const messages = {
"getting_started.open_source_notice": "Glitchsocは{Mastodon}によるフリーなオープンソースソフトウェアです。誰でもGitHub{github})から開発に參加したり、問題を報告したりできます。",
"layout.auto": "自動",
"layout.current_is": "あなたの現在のレイアウト:",
@ -44,4 +46,6 @@
"notification_purge.btn_none": "選択\n解除",
"notification_purge.btn_invert": "選択を\n反転",
"notification_purge.btn_apply": "選択したものを\n削除"
}
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/ko.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/nl.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/no.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/oc.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,48 @@
import inherited from 'mastodon/locales/pl.json';
const messages = {
'getting_started.open_source_notice': 'Glitchsoc jest wolnym i otwartoźródłowym forkiem oprogramowania {Mastodon}. Możesz współtworzyć projekt lub zgłaszać błędy na GitHubie pod adresem {github}.',
'layout.auto': 'Automatyczny',
'layout.current_is': 'Twój obecny układ to:',
'layout.desktop': 'Desktopowy',
'layout.mobile': 'Mobilny',
'navigation_bar.app_settings': 'Ustawienia aplikacji',
'getting_started.onboarding': 'Rozejrzyj się',
'onboarding.page_one.federation': '{domain} jest \'instancją\' Mastodona. Mastodon to sieć działających niezależnie serwerów tworzących jedną sieć społecznościową. Te serwery nazywane są instancjami.',
'onboarding.page_one.welcome': 'Witamy na {domain}!',
'onboarding.page_six.github': '{domain} jest oparty na Glitchsoc. Glitchsoc jest {forkiem} {Mastodon}a kompatybilnym z każdym klientem i aplikacją Mastodona. Glitchsoc jest całkowicie wolnym i otwartoźródłowym oprogramowaniem. Możesz zgłaszać błędy i sugestie funkcji oraz współtworzyć projekt na {github}.',
'settings.auto_collapse': 'Automatyczne zwijanie',
'settings.auto_collapse_all': 'Wszystko',
'settings.auto_collapse_lengthy': 'Długie wpisy',
'settings.auto_collapse_media': 'Wpisy z zawartością multimedialną',
'settings.auto_collapse_notifications': 'Powiadomienia',
'settings.auto_collapse_reblogs': 'Podbicia',
'settings.auto_collapse_replies': 'Odpowiedzi',
'settings.close': 'Zamknij',
'settings.collapsed_statuses': 'Zwijanie wpisów',
'settings.enable_collapsed': 'Włącz zwijanie wpisów',
'settings.general': 'Ogólne',
'settings.image_backgrounds': 'Obrazy w tle',
'settings.image_backgrounds_media': 'Wyświetlaj zawartość multimedialną zwiniętych wpisów',
'settings.image_backgrounds_users': 'Nadaj tło zwiniętym wpisom',
'settings.media': 'Zawartość multimedialna',
'settings.media_letterbox': 'Letterbox media',
'settings.media_fullwidth': 'Podgląd zawartości multimedialnej o pełnej szerokości',
'settings.preferences': 'Preferencje użyytkownika',
'settings.wide_view': 'Szeroki widok (tylko w trybie desktopowym)',
'settings.navbar_under': 'Pasek nawigacji na dole (tylko w trybie mobilnym)',
'status.collapse': 'Zwiń',
'status.uncollapse': 'Rozwiń',
'notification.markForDeletion': 'Oznacz do usunięcia',
'notifications.clear': 'Wyczyść wszystkie powiadomienia',
'notifications.marked_clear_confirmation': 'Czy na pewno chcesz bezpowrtonie usunąć wszystkie powiadomienia?',
'notifications.marked_clear': 'Usuń zaznaczone powiadomienia',
'notification_purge.btn_all': 'Zaznacz\nwszystkie',
'notification_purge.btn_none': 'Odznacz\nwszystkie',
'notification_purge.btn_invert': 'Odwróć\nzaznaczenie',
'notification_purge.btn_apply': 'Usuń\nzaznaczone',
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/pt-BR.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/pt.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/ru.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/sv.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/th.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/tr.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/uk.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/zh-CN.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/zh-HK.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,7 @@
import inherited from 'mastodon/locales/zh-TW.json';
const messages = {
// No translations available.
};
export default Object.assign({}, inherited, messages);

View File

@ -0,0 +1,6 @@
en:
flavours:
glitch: Glitch Edition
skins:
glitch:
default: Default

View File

@ -20,6 +20,12 @@ pack:
settings:
share: packs/share.js
# (OPTIONAL) The directory which contains localization files for
# the flavour, relative to this directory. The contents of this
# directory must be `.js` or `.json` files whose names correspond to
# language tags and whose default exports are a messages object.
locales: locales
# (OPTIONAL) The directory which contains the pack files.
# Defaults to the theme directory (`app/javascript/themes/[theme]`),
# which should be sufficient for like 99% of use-cases lol.

View File

@ -0,0 +1,6 @@
en:
flavours:
vanilla: Vanilla Mastodon
skins:
vanilla:
default: Default

View File

@ -20,13 +20,17 @@ pack:
settings:
share: share.js
# (OPTIONAL) The directory which contains localization files for
# the flavour, relative to this directory.
locales: ../../mastodon/locales
# (OPTIONAL) The directory which contains the pack files.
# Defaults to the theme directory (`app/javascript/themes/[theme]`),
# but in the case of the vanilla Mastodon theme the pack files are
# Defaults to this directory (`app/javascript/flavour/[flavour]`),
# but in the case of the vanilla Mastodon flavour the pack files are
# somewhere else.
pack_directory: app/javascript/packs
# (OPTIONAL) By default the theme will fallback to the default theme
# (OPTIONAL) By default the theme will fallback to the default flavour
# if a particular pack is not provided. You can specify different
# fallbacks here, or disable fallback behaviours altogether by
# specifying a `null` value.

View File

@ -1,46 +0,0 @@
{
"getting_started.open_source_notice": "Glitchsoc is free open source software forked from {Mastodon}. You can contribute or report issues on GitHub at {github}.",
"layout.auto": "Auto",
"layout.current_is": "Your current layout is:",
"layout.desktop": "Desktop",
"layout.mobile": "Mobile",
"navigation_bar.app_settings": "App settings",
"getting_started.onboarding": "Show me around",
"onboarding.page_one.federation": "{domain} is an 'instance' of Mastodon. Mastodon is a network of independent servers joining up to make one larger social network. We call these servers instances.",
"onboarding.page_one.welcome": "Welcome to {domain}!",
"onboarding.page_six.github": "{domain} runs on Glitchsoc. Glitchsoc is a friendly {fork} of {Mastodon}, and is compatible with any Mastodon instance or app. Glitchsoc is entirely free and open-source. You can report bugs, request features, or contribute to the code on {github}.",
"settings.auto_collapse": "Automatic collapsing",
"settings.auto_collapse_all": "Everything",
"settings.auto_collapse_lengthy": "Lengthy toots",
"settings.auto_collapse_media": "Toots with media",
"settings.auto_collapse_notifications": "Notifications",
"settings.auto_collapse_reblogs": "Boosts",
"settings.auto_collapse_replies": "Replies",
"settings.close": "Close",
"settings.collapsed_statuses": "Collapsed toots",
"settings.enable_collapsed": "Enable collapsed toots",
"settings.general": "General",
"settings.image_backgrounds": "Image backgrounds",
"settings.image_backgrounds_media": "Preview collapsed toot media",
"settings.image_backgrounds_users": "Give collapsed toots an image background",
"settings.media": "Media",
"settings.media_letterbox": "Letterbox media",
"settings.media_fullwidth": "Full-width media previews",
"settings.preferences": "User preferences",
"settings.wide_view": "Wide view (Desktop mode only)",
"settings.navbar_under": "Navbar at the bottom (Mobile only)",
"status.collapse": "Collapse",
"status.uncollapse": "Uncollapse",
"home.column_settings.show_direct": "Show DMs",
"notification.markForDeletion": "Mark for deletion",
"notifications.clear": "Clear all my notifications",
"notifications.marked_clear_confirmation": "Are you sure you want to permanently clear all selected notifications?",
"notifications.marked_clear": "Clear selected notifications",
"notification_purge.btn_all": "Select\nall",
"notification_purge.btn_none": "Select\nnone",
"notification_purge.btn_invert": "Invert\nselection",
"notification_purge.btn_apply": "Clear\nselected"
}

View File

@ -1,44 +0,0 @@
{
"getting_started.open_source_notice": "Glitchsoc jest wolnym i otwartoźródłowym forkiem oprogramowania {Mastodon}. Możesz współtworzyć projekt lub zgłaszać błędy na GitHubie pod adresem {github}.",
"layout.auto": "Automatyczny",
"layout.current_is": "Twój obecny układ to:",
"layout.desktop": "Desktopowy",
"layout.mobile": "Mobilny",
"navigation_bar.app_settings": "Ustawienia aplikacji",
"getting_started.onboarding": "Rozejrzyj się",
"onboarding.page_one.federation": "{domain} jest 'instancją' Mastodona. Mastodon to sieć działających niezależnie serwerów tworzących jedną sieć społecznościową. Te serwery nazywane są instancjami.",
"onboarding.page_one.welcome": "Witamy na {domain}!",
"onboarding.page_six.github": "{domain} jest oparty na Glitchsoc. Glitchsoc jest {forkiem} {Mastodon}a kompatybilnym z każdym klientem i aplikacją Mastodona. Glitchsoc jest całkowicie wolnym i otwartoźródłowym oprogramowaniem. Możesz zgłaszać błędy i sugestie funkcji oraz współtworzyć projekt na {github}.",
"settings.auto_collapse": "Automatyczne zwijanie",
"settings.auto_collapse_all": "Wszystko",
"settings.auto_collapse_lengthy": "Długie wpisy",
"settings.auto_collapse_media": "Wpisy z zawartością multimedialną",
"settings.auto_collapse_notifications": "Powiadomienia",
"settings.auto_collapse_reblogs": "Podbicia",
"settings.auto_collapse_replies": "Odpowiedzi",
"settings.close": "Zamknij",
"settings.collapsed_statuses": "Zwijanie wpisów",
"settings.enable_collapsed": "Włącz zwijanie wpisów",
"settings.general": "Ogólne",
"settings.image_backgrounds": "Obrazy w tle",
"settings.image_backgrounds_media": "Wyświetlaj zawartość multimedialną zwiniętych wpisów",
"settings.image_backgrounds_users": "Nadaj tło zwiniętym wpisom",
"settings.media": "Zawartość multimedialna",
"settings.media_letterbox": "Letterbox media",
"settings.media_fullwidth": "Podgląd zawartości multimedialnej o pełnej szerokości",
"settings.preferences": "Preferencje użyytkownika",
"settings.wide_view": "Szeroki widok (tylko w trybie desktopowym)",
"settings.navbar_under": "Pasek nawigacji na dole (tylko w trybie mobilnym)",
"status.collapse": "Zwiń",
"status.uncollapse": "Rozwiń",
"notification.markForDeletion": "Oznacz do usunięcia",
"notifications.clear": "Wyczyść wszystkie powiadomienia",
"notifications.marked_clear_confirmation": "Czy na pewno chcesz bezpowrtonie usunąć wszystkie powiadomienia?",
"notifications.marked_clear": "Usuń zaznaczone powiadomienia",
"notification_purge.btn_all": "Zaznacz\nwszystkie",
"notification_purge.btn_none": "Odznacz\nwszystkie",
"notification_purge.btn_invert": "Odwróć\nzaznaczenie",
"notification_purge.btn_apply": "Usuń\nzaznaczone"
}

View File

@ -0,0 +1,4 @@
en:
skins:
vanilla:
win95: 95

View File

@ -15,6 +15,14 @@ class Themes
Dir.glob(Rails.root.join('app', 'javascript', 'flavours', '*', 'theme.yml')) do |path|
data = YAML.load_file(path)
name = File.basename(File.dirname(path))
if data['locales']
locales = []
Dir.glob(File.join(File.dirname(path), data['locales'], '*.{js,json}')) do |locale|
localeName = File.basename(locale, File.extname(locale))
locales.push(localeName) unless localeName.match(/defaultMessages|whitelist|index/)
end
data['locales'] = locales
end
if data['pack']
data['name'] = name
data['skin'] = { 'default' => [] }

View File

@ -19,7 +19,11 @@
= title
= javascript_pack_tag "locales", integrity: true, crossorigin: 'anonymous'
= javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
- if @theme
- if @theme[:supported_locales].include? I18n.locale.to_s
= javascript_pack_tag "locales/#{@theme[:flavour]}/#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
- elsif @theme[:supported_locales].include? 'en'
= javascript_pack_tag "locales/#{@theme[:flavour]}/en", integrity: true, crossorigin: 'anonymous'
= csrf_meta_tags
= yield :header_tags

View File

@ -27,8 +27,8 @@
.fields-group
- if Themes.instance.flavours.size > 1
= f.input :setting_flavour, collection: Themes.instance.flavours, label_method: lambda { |flavour| I18n.t("themes.#{flavour}", default: flavour) }, wrapper: :with_label, include_blank: false
= f.input :setting_skin, collection: Themes.instance.skins_for(current_flavour), label_method: lambda { |skin| I18n.t("themes.#{current_flavour}.skins.#{skin}", default: skin) }, wrapper: :with_label, include_blank: false
= f.input :setting_flavour, collection: Themes.instance.flavours, label_method: lambda { |flavour| I18n.t("flavours.#{flavour}", default: flavour) }, wrapper: :with_label, include_blank: false
= f.input :setting_skin, collection: Themes.instance.skins_for(current_flavour), label_method: lambda { |skin| I18n.t("skins.#{current_flavour}.#{skin}", default: skin) }, wrapper: :with_label, include_blank: false
= f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label
= f.input :setting_boost_modal, as: :boolean, wrapper: :with_label

View File

@ -0,0 +1,6 @@
# frozen_string_literal: true
I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'flavours', '*', 'names.{rb,yml}').to_s]
I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'flavours', '*', 'names', '*.{rb,yml}').to_s]
I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'skins', '*', '*', 'names.{rb,yml}').to_s]
I18n.load_path += Dir[Rails.root.join('app', 'javascript', 'skins', '*', '*', 'names', '*.{rb,yml}').to_s]

View File

@ -678,8 +678,6 @@ ca:
<p>Originalment adaptat a la <a href="https://github.com/discourse/discourse">política de privadesa del Discurs</a>.</p>
title: "%{instance} Condicions del servei i política de privadesa"
themes:
default: Mastodont
time:
formats:
default: "%b %d, %Y, %H:%M"

View File

@ -687,8 +687,6 @@ en:
<p>Originally adapted from the <a href="https://github.com/discourse/discourse">Discourse privacy policy</a>.</p>
title: "%{instance} Terms of Service and Privacy Policy"
themes:
default: Mastodon
time:
formats:
default: "%b %d, %Y, %H:%M"

View File

@ -678,8 +678,6 @@ es:
<p>Adaptado originalmente del <a href="https://github.com/discourse/discourse">discurso de las políticas de privacidad</a>.</p>
title: Términos del Servicio y Políticas de Privacidad de %{instance}
themes:
default: Mastodon
time:
formats:
default: "%d de %b del %Y, %H:%M"

View File

@ -677,8 +677,6 @@ fr:
<p>Originellement adapté à partir de la politique de confidentialité de <a href="https://github.com/discourse/discourse">Discourse</a>.</p>
title: "%{instance} Conditions dutilisations et politique de confidentialité"
themes:
default: Mastodon
time:
formats:
default: "%d %b %Y, %H:%M"

View File

@ -693,8 +693,6 @@ pl:
<p>Tekst bazuje na <a href="https://github.com/discourse/discourse">polityce prywatności Discourse</a>.</p>
title: Zasady korzystania i polityka prywatności %{instance}
themes:
default: Mastodon
time:
formats:
default: "%b %d, %Y, %H:%M"

View File

@ -30,6 +30,9 @@ for (let i = 0; i < flavourFiles.length; i++) {
if (!data.pack_directory) {
data.pack_directory = dirname(flavourFile);
}
if (data.locales) {
data.locales = join(dirname(flavourFile), data.locales);
}
if (data.pack && typeof data.pack === 'object') {
flavours[data.name] = data;
}
@ -45,7 +48,7 @@ for (let i = 0; i < skinFiles.length; i++) {
const data = flavours[name].skin;
if (lstatSync(skinFile).isDirectory()) {
data[skin] = {};
const skinPacks = glob.sync(resolve(skinFile, '*.{css,scss}'));
const skinPacks = glob.sync(join(skinFile, '*.{css,scss}'));
for (let j = 0; j < skinPacks.length; j++) {
const pack = skinPacks[i];
data[skin][basename(pack, extname(pack))] = pack;

View File

@ -1,70 +1,66 @@
// A message from upstream:
// ========================
// To avoid adding a lot of boilerplate, locale packs are
// automatically generated here. These are written into the tmp/
// directory and then used to generate locale_en.js, locale_fr.js, etc.
const fs = require('fs');
const path = require('path');
// Glitch note:
// ============
// This code has been entirely rewritten to support glitch flavours.
// However, the underlying process is exactly the same.
const { existsSync, readdirSync, writeFileSync } = require('fs');
const { join, resolve } = require('path');
const rimraf = require('rimraf');
const mkdirp = require('mkdirp');
const { flavours } = require('./configuration.js');
const localesJsonPath = path.join(__dirname, '../../app/javascript/mastodon/locales');
const locales = fs.readdirSync(localesJsonPath).filter(filename => {
return /\.json$/.test(filename) &&
!/defaultMessages/.test(filename) &&
!/whitelist/.test(filename);
}).map(filename => filename.replace(/\.json$/, ''));
const outPath = path.join(__dirname, '../../tmp/packs');
rimraf.sync(outPath);
mkdirp.sync(outPath);
const outPaths = [];
locales.forEach(locale => {
const localePath = path.join(outPath, `locale_${locale}.js`);
const baseLocale = locale.split('-')[0]; // e.g. 'zh-TW' -> 'zh'
const localeDataPath = [
// first try react-intl
`../../node_modules/react-intl/locale-data/${baseLocale}.js`,
// then check locales/locale-data
`../../app/javascript/mastodon/locales/locale-data/${baseLocale}.js`,
// fall back to English (this is what react-intl does anyway)
'../../node_modules/react-intl/locale-data/en.js',
].filter(filename => fs.existsSync(path.join(outPath, filename)))
.map(filename => filename.replace(/..\/..\/node_modules\//, ''))[0];
let glitchInject = `
const mergedMessages = messages;
`;
const glitchPath = `../../app/javascript/glitch/locales/${locale}.json`;
if (fs.existsSync(path.join(outPath, glitchPath))) {
glitchInject = `
import glitchMessages from ${JSON.stringify(glitchPath)};
let mergedMessages = messages;
Object.keys(glitchMessages).forEach(function (key) {
mergedMessages[key] = glitchMessages[key];
});
`;
module.exports = Object.keys(flavours).reduce(function (map, entry) {
const flavour = flavours[entry];
if (!flavour.locales) {
return map;
}
const locales = readdirSync(flavour.locales).filter(
filename => /\.js(?:on)?$/.test(filename) && !/defaultMessages|whitelist|index/.test(filename)
);
const outPath = resolve('tmp', 'locales', entry);
const localeContent = `//
// locale_${locale}.js
rimraf.sync(outPath);
mkdirp.sync(outPath);
locales.forEach(function (locale) {
const localeName = locale.replace(/\.js(?:on)?$/, '');
const localePath = join(outPath, `${localeName}.js`);
const baseLocale = localeName.split('-')[0]; // e.g. 'zh-TW' -> 'zh'
const localeDataPath = [
// first try react-intl
`node_modules/react-intl/locale-data/${baseLocale}.js`,
// then check locales/locale-data
`app/javascript/locales/locale-data/${baseLocale}.js`,
// fall back to English (this is what react-intl does anyway)
'node_modules/react-intl/locale-data/en.js',
].filter(
filename => existsSync(filename)
).map(
filename => filename.replace(/(?:node_modules|app\/javascript)\//, '')
)[0];
const localeContent = `//
// locales/${entry}/${localeName}.js
// automatically generated by generateLocalePacks.js
//
import messages from '../../app/javascript/mastodon/locales/${locale}.json';
import localeData from ${JSON.stringify(localeDataPath)};
import messages from '../../../${flavour.locales}/${locale.replace(/\.js$/, '')}';
import localeData from '${localeDataPath}';
import { setLocale } from 'locales';
${glitchInject}
setLocale({messages: mergedMessages, localeData: localeData});
`;
fs.writeFileSync(localePath, localeContent, 'utf8');
outPaths.push(localePath);
setLocale({
localeData,
messages,
});
`;
writeFileSync(localePath, localeContent, 'utf8');
map[`locales/${entry}/${localeName}`] = localePath;
});
module.exports = outPaths;
return map;
}, {});

View File

@ -1,13 +1,12 @@
// Note: You must restart bin/webpack-dev-server for changes to take effect
const webpack = require('webpack');
const { basename, join, resolve } = require('path');
const { join, resolve } = require('path');
const { sync } = require('glob');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const extname = require('path-complete-extname');
const { env, settings, core, flavours, output, loadersDir } = require('./configuration.js');
const localePackPaths = require('./generateLocalePacks');
const localePacks = require('./generateLocalePacks');
function reducePacks (data, into = {}) {
if (!data.pack) {
@ -48,11 +47,7 @@ function reducePacks (data, into = {}) {
module.exports = {
entry: Object.assign(
{ locales: resolve('app', 'javascript', 'locales') },
localePackPaths.reduce((map, entry) => {
const localMap = map;
localMap[basename(entry, extname(entry, extname(entry)))] = resolve(entry);
return localMap;
}, {}),
localePacks,
reducePacks(core),
Object.keys(flavours).reduce((map, entry) => reducePacks(flavours[entry], map), {})
),