|
9 | 9 | data-controller="better-together--markdown-block better-together--dependent-fields"> |
10 | 10 | <!-- Radio buttons to choose between source or file --> |
11 | 11 | <div class="mb-3"> |
12 | | - <%= label_tag nil, 'Markdown Source', class: 'form-label' %> |
| 12 | + <%= label_tag nil, t('better_together.content.blocks.markdown.fields.markdown_source'), class: 'form-label' %> |
13 | 13 | <div class="form-check"> |
14 | 14 | <%= radio_button_tag "#{scope}[markdown_source_type]", 'inline', inline_selected, |
15 | 15 | class: 'form-check-input', |
|
19 | 19 | 'better-together--markdown-block-target': 'sourceTypeRadio', |
20 | 20 | 'better-together--dependent-fields-target': 'controlField' |
21 | 21 | } %> |
22 | | - <%= label_tag inline_radio_id, 'Write Markdown Inline', class: 'form-check-label' %> |
| 22 | + <%= label_tag inline_radio_id, t('better_together.content.blocks.markdown.fields.write_inline'), class: 'form-check-label' %> |
23 | 23 | </div> |
24 | 24 | <div class="form-check"> |
25 | 25 | <%= radio_button_tag "#{scope}[markdown_source_type]", 'file', block.markdown_file_path.present?, |
|
30 | 30 | 'better-together--markdown-block-target': 'sourceTypeRadio', |
31 | 31 | 'better-together--dependent-fields-target': 'controlField' |
32 | 32 | } %> |
33 | | - <%= label_tag file_radio_id, 'Reference a Markdown File', class: 'form-check-label' %> |
| 33 | + <%= label_tag file_radio_id, t('better_together.content.blocks.markdown.fields.reference_file'), class: 'form-check-label' %> |
34 | 34 | </div> |
35 | 35 | </div> |
36 | 36 |
|
37 | | - <!-- Inline markdown source textarea --> |
| 37 | + <!-- Inline markdown source textarea with locale support --> |
38 | 38 | <div class="mb-3 markdown-inline-field <%= 'hidden-field' unless inline_selected %>" |
39 | 39 | data-better-together--markdown-block-target="inlineField" |
40 | 40 | data-better-together--dependent-fields-target="dependentField" |
41 | 41 | data-dependent-fields-control="<%= inline_radio_id %>" |
42 | 42 | data-show-if-control_<%= inline_radio_id %>="inline"> |
43 | | - <%= label_tag "#{scope}[markdown_source]", 'Markdown Content', class: 'form-label' %> |
44 | | - <%= text_area_tag "#{scope}[markdown_source]", |
45 | | - block.markdown_source, |
46 | | - class: "form-control font-monospace#{' is-invalid' if block.errors[:markdown_source].any?}", |
47 | | - rows: 12, |
48 | | - placeholder: "# Your Markdown Here\n\nWrite your markdown content...", |
49 | | - data: { 'better-together--markdown-block-target': 'sourceTextarea' }, |
50 | | - disabled: !inline_selected %> |
51 | 43 |
|
52 | | - <% if block.errors[:markdown_source].any? %> |
53 | | - <div class="invalid-feedback"> |
54 | | - <%= block.errors[:markdown_source].join(", ") %> |
55 | | - </div> |
56 | | - <% end %> |
| 44 | + <%= render partial: 'better_together/content/blocks/fields/shared/translatable_text_field', |
| 45 | + locals: { |
| 46 | + model: block, |
| 47 | + scope: scope, |
| 48 | + temp_id: temp_id, |
| 49 | + attribute: 'markdown_source' |
| 50 | + } %> |
57 | 51 |
|
58 | 52 | <small class="form-text text-muted mt-2"> |
59 | | - Write your markdown content directly. Supports GitHub-flavored markdown including tables, code blocks, and more. |
| 53 | + <%= t('better_together.content.blocks.markdown.help.inline_content') %> |
60 | 54 | </small> |
61 | 55 | </div> |
62 | 56 |
|
|
66 | 60 | data-better-together--dependent-fields-target="dependentField" |
67 | 61 | data-dependent-fields-control="<%= file_radio_id %>" |
68 | 62 | data-show-if-control_<%= file_radio_id %>="file"> |
69 | | - <%= label_tag "#{scope}[markdown_file_path]", 'Markdown File Path', class: 'form-label' %> |
| 63 | + <%= label_tag "#{scope}[markdown_file_path]", t('better_together.content.blocks.markdown.fields.file_path'), class: 'form-label' %> |
70 | 64 | <%= text_field_tag "#{scope}[markdown_file_path]", |
71 | 65 | block.markdown_file_path, |
72 | 66 | class: "form-control font-monospace#{' is-invalid' if block.errors[:markdown_file_path].any?}", |
73 | | - placeholder: "docs/README.md or /absolute/path/to/file.md", |
| 67 | + placeholder: t('better_together.content.blocks.markdown.fields.file_path_placeholder'), |
74 | 68 | data: { 'better-together--markdown-block-target': 'filePathInput' }, |
75 | 69 | disabled: inline_selected %> |
76 | 70 |
|
|
81 | 75 | <% end %> |
82 | 76 |
|
83 | 77 | <small class="form-text text-muted mt-2"> |
84 | | - Path to a markdown file. Can be relative to Rails.root (e.g., <code>docs/README.md</code>) or absolute (e.g., <code>/path/to/file.md</code>). File must have a .md or .markdown extension. |
| 78 | + <%= t('better_together.content.blocks.markdown.help.file_path') %> |
| 79 | + <br> |
| 80 | + <strong><%= t('better_together.content.blocks.markdown.help.localized_files') %></strong> |
85 | 81 | </small> |
| 82 | + |
| 83 | + <!-- Auto-sync from file option --> |
| 84 | + <div class="form-check mt-3"> |
| 85 | + <%= check_box_tag "#{scope}[auto_sync_from_file]", |
| 86 | + '1', |
| 87 | + block.auto_sync_from_file, |
| 88 | + class: 'form-check-input', |
| 89 | + id: "#{temp_id}_auto_sync", |
| 90 | + disabled: inline_selected %> |
| 91 | + <%= label_tag "#{temp_id}_auto_sync", |
| 92 | + t('better_together.content.blocks.markdown.fields.auto_sync'), |
| 93 | + class: 'form-check-label' %> |
| 94 | + <small class="form-text text-muted d-block"> |
| 95 | + <%= t('better_together.content.blocks.markdown.help.auto_sync') %> |
| 96 | + </small> |
| 97 | + </div> |
| 98 | + |
| 99 | + <!-- Available translations indicator --> |
| 100 | + <% if block.markdown_file_path.present? %> |
| 101 | + <div class="alert alert-info mt-3 mb-0"> |
| 102 | + <strong><i class="fa fa-info-circle"></i> <%= t('better_together.content.blocks.markdown.help.available_translations') %></strong> |
| 103 | + <% |
| 104 | + base_path = block.markdown_file_path.sub(/\.(md|markdown)$/i, '') |
| 105 | + I18n.available_locales.each do |locale| |
| 106 | + locale_file = "#{base_path}.#{locale}.md" |
| 107 | + # Try to resolve the file path |
| 108 | + file_path = if Pathname.new(locale_file).absolute? |
| 109 | + Pathname.new(locale_file) |
| 110 | + else |
| 111 | + Rails.root.join(locale_file) |
| 112 | + end |
| 113 | + file_exists = File.exist?(file_path) |
| 114 | + %> |
| 115 | + <span class="badge <%= file_exists ? 'bg-success' : 'bg-secondary' %> me-1"> |
| 116 | + <%= locale.upcase %> <%= file_exists ? '✓' : '✗' %> |
| 117 | + </span> |
| 118 | + <% end %> |
| 119 | + </div> |
| 120 | + <% end %> |
86 | 121 | </div> |
87 | 122 |
|
88 | 123 | <!-- Preview area --> |
89 | 124 | <div class="mb-3"> |
90 | 125 | <div class="d-flex justify-content-between align-items-center mb-2"> |
91 | | - <%= label_tag nil, 'Preview', class: 'form-label mb-0' %> |
| 126 | + <%= label_tag nil, t('better_together.content.blocks.markdown.fields.preview'), class: 'form-label mb-0' %> |
92 | 127 | <button type="button" |
93 | 128 | class="btn btn-sm btn-outline-secondary" |
94 | 129 | data-action="click->better-together--markdown-block#refreshPreview"> |
95 | | - <i class="fa fa-refresh"></i> Refresh Preview |
| 130 | + <i class="fa fa-refresh"></i> <%= t('better_together.content.blocks.markdown.fields.refresh_preview') %> |
96 | 131 | </button> |
97 | 132 | </div> |
98 | 133 | <div class="border rounded p-3 bg-light markdown-content" |
|
102 | 137 | <%= block.rendered_html %> |
103 | 138 | <% else %> |
104 | 139 | <p class="text-muted mb-0"> |
105 | | - <em>Preview will appear here...</em> |
| 140 | + <em><%= t('better_together.content.blocks.markdown.help.preview_placeholder') %></em> |
106 | 141 | </p> |
107 | 142 | <% end %> |
108 | 143 | </div> |
|
0 commit comments