jekyll-l10n 1.0.7 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89d7ff23e3bc3ebcb0f27aa77665ac410afcb96ebff6b5abb1992349a68b1859
|
|
4
|
+
data.tar.gz: b88c9b6283535514aebd9a77e2d5fe4f01407f008e5de2b8d21e0b30cb76bc85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3fd8a693edcc99826f5f1beff125706b2dab0d39cccf21e393dfc2895578ddfaead57c309b1dbb0ba8cfe4d14c280fab34a33c895f87bc47a86ad972c9a395d2
|
|
7
|
+
data.tar.gz: 69b96d33ceaf4bcbe8e2ab8073e7d6fe549e1cfd5e2b09cce41ea1f32def1df650c8c7347ff8b15c230c7c237b3073ff77b015c8881b291b2f3a6c50ed020fa1
|
|
@@ -74,8 +74,24 @@ module Jekyll
|
|
|
74
74
|
|
|
75
75
|
def should_localize_page?(page)
|
|
76
76
|
return false if page.data["localized"] == true
|
|
77
|
+
return false unless page.data["with_locales"] == true
|
|
78
|
+
|
|
79
|
+
# Only localize HTML pages - exclude static assets
|
|
80
|
+
# Check multiple conditions to be safe:
|
|
81
|
+
# 1. output_ext must be .html
|
|
82
|
+
# 2. path must not contain common asset directories
|
|
83
|
+
is_html = page.output_ext == ".html"
|
|
84
|
+
is_not_asset = !page.path.match?(%r!/(assets|vendor|node_modules|\..*)/!i)
|
|
85
|
+
|
|
86
|
+
# Debug: Log which pages are being skipped
|
|
87
|
+
if !is_html
|
|
88
|
+
Jekyll.logger.debug "Localization",
|
|
89
|
+
"Skipping non-HTML: #{page.path} (ext: #{page.output_ext})"
|
|
90
|
+
elsif !is_not_asset
|
|
91
|
+
Jekyll.logger.debug "Localization", "Skipping asset: #{page.path}"
|
|
92
|
+
end
|
|
77
93
|
|
|
78
|
-
|
|
94
|
+
is_html && is_not_asset
|
|
79
95
|
end
|
|
80
96
|
|
|
81
97
|
def get_page_locales(page)
|
|
@@ -95,28 +95,38 @@ module Jekyll
|
|
|
95
95
|
#
|
|
96
96
|
# Returns the page's URL with a locale prefix. For example, if the source page URL is
|
|
97
97
|
# '/path/to/page/', this returns '/es/path/to/page/' for locale 'es'.
|
|
98
|
-
#
|
|
98
|
+
# For HTML pages, URLs end with a trailing slash. For assets, the file extension is preserved.
|
|
99
99
|
#
|
|
100
|
-
# @return [String] The locale-prefixed URL
|
|
100
|
+
# @return [String] The locale-prefixed URL with optional trailing slash
|
|
101
|
+
# (e.g., '/es/path/to/page/' or '/es/assets/style.css')
|
|
101
102
|
def url
|
|
102
103
|
url = "/#{@locale}#{@original_url}"
|
|
103
|
-
|
|
104
|
+
# Only add trailing slash for directory URLs (no file extension)
|
|
105
|
+
url += "/" unless url.end_with?("/") || url =~ %r!\.[a-zA-Z0-9]+$!
|
|
104
106
|
url
|
|
105
107
|
end
|
|
106
108
|
|
|
107
109
|
# Get the destination file path for this localized page
|
|
108
110
|
#
|
|
109
|
-
# Computes the full file system path where this page's
|
|
110
|
-
# For
|
|
111
|
+
# Computes the full file system path where this page's content will be written.
|
|
112
|
+
# For HTML pages with URL '/es/path/to/page/', this returns 'dest/es/path/to/page/index.html'.
|
|
113
|
+
# For assets with URL '/es/assets/style.css', this returns 'dest/es/assets/style.css'.
|
|
111
114
|
#
|
|
112
115
|
# @param dest [String, nil] The destination directory (defaults to nil, which uses
|
|
113
116
|
# site config destination)
|
|
114
|
-
# @return [String] The full file system path for the output
|
|
117
|
+
# @return [String] The full file system path for the output file
|
|
115
118
|
def destination(dest = nil)
|
|
116
119
|
dest ||= @site.config["destination"]
|
|
117
120
|
url_path = url
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
|
|
122
|
+
# Only use index.html for HTML pages
|
|
123
|
+
if @output_ext == ".html"
|
|
124
|
+
url_path += "/" unless url_path.end_with?("/")
|
|
125
|
+
"#{dest}#{url_path}index.html"
|
|
126
|
+
else
|
|
127
|
+
# For assets, preserve the file extension
|
|
128
|
+
"#{dest}#{url_path}"
|
|
129
|
+
end
|
|
120
130
|
end
|
|
121
131
|
|
|
122
132
|
# Convert this localized page to Liquid template data
|
|
@@ -30,13 +30,22 @@ module Jekyll
|
|
|
30
30
|
|
|
31
31
|
# Convert a URL to a file system path.
|
|
32
32
|
#
|
|
33
|
-
# Converts Jekyll URL to the path it would be written to on disk
|
|
34
|
-
#
|
|
33
|
+
# Converts Jekyll URL to the path it would be written to on disk.
|
|
34
|
+
# For URLs with file extensions (assets), preserves the extension.
|
|
35
|
+
# For directory-style URLs, uses index.html.
|
|
35
36
|
#
|
|
36
|
-
# @param url [String] Jekyll URL (e.g., '/docs/page.html')
|
|
37
|
-
# @return [String] File path (e.g., 'docs/page.html/index.html')
|
|
37
|
+
# @param url [String] Jekyll URL (e.g., '/docs/page.html' or '/assets/style.css')
|
|
38
|
+
# @return [String] File path (e.g., 'docs/page.html/index.html' or 'assets/style.css')
|
|
38
39
|
def url_to_file_path(url)
|
|
39
|
-
|
|
40
|
+
normalized = normalize_url(url)
|
|
41
|
+
|
|
42
|
+
# Preserve file extensions for assets (css, js, etc.)
|
|
43
|
+
# Only add /index.html for directory-style URLs
|
|
44
|
+
if %r!\.[a-zA-Z0-9]+$!.match?(normalized)
|
|
45
|
+
normalized
|
|
46
|
+
else
|
|
47
|
+
"#{normalized}/index.html"
|
|
48
|
+
end
|
|
40
49
|
end
|
|
41
50
|
|
|
42
51
|
# Convert a URL to a PO page path for translation files.
|