middleman-transpath 0.0.2 β†’ 0.0.3

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
  SHA1:
3
- metadata.gz: c2f16960bde4558bb9f240f1d085a686ef03bcf8
4
- data.tar.gz: 59a485d0749aebfabda6ae98b76878d6c0f32244
3
+ metadata.gz: 730565facedcf1813f664e661737b26023394fa0
4
+ data.tar.gz: 02fa8c35fce355e641ef37062da9ee321d9ab001
5
5
  SHA512:
6
- metadata.gz: 3d725bfef5f444c5e495cb9feee11c3816cce4b9f78e36c149ab7d4a099dd97a3e742a1387446b1ab23e1c81f608b037b149d5cf55fe043feb47ec0ccdde36dd
7
- data.tar.gz: 116dd831464a68e117b8bd39fff2ace40e0c098f9411068a0b3c6bcf3063a5072fa37ae4cdd591e7d8c42c315a613d8bc173fa90049d8b70806d3875bca5a114
6
+ metadata.gz: 8bf40a6402b7cb5dc0405fcd042989a75044219a5f1d626defe4b995a798d8d3d0c1b052eeee5df7a8149fbdf9705cfcd8c919ab240bfcb023367d2784265835
7
+ data.tar.gz: 0e541458b57bd2fb7c3da3ba7efa4aa825028d9a5de2aad86d9345fc0a08f872a9199769e261ec7cd3c9319e812f189662468aaa48b870ab049f868b3f402e54
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Middleman-transpath
2
2
  You're using i18n for your middleman website ? This extension is for you !
3
+ ![demo](demo.gif)
3
4
 
4
5
  ## Why ?
5
6
  Translating path with middleman, or access to the same page but different locale and slug is not integrate by default in middleman-i18n.
@@ -15,6 +16,25 @@ and this to your **config.rb**: `activate :transpath`
15
16
  ## Solution ?
16
17
  Yep, easily. Install and configure i18n with your favorite locales, and don't forget to specify your default locale (for example : `activate :i18n, :mount_at_root => :fr` in your **config.rb**, to use French as default locale), check the [documentation](https://middlemanapp.com/advanced/localization/)
17
18
 
19
+ ## Configuration
20
+ By default, this is the following configuration:
21
+ ```YAML
22
+ t.label = {
23
+ en: 'πŸ‡ΊπŸ‡Έ - EN',
24
+ fr: 'πŸ‡«πŸ‡· - FR'
25
+ }
26
+ ```
27
+ You can add others locales, or rename these, just like this in your config.rb:
28
+ ```YAML
29
+ activate :transpath do
30
+ t.label = {
31
+ en: 'EN',
32
+ fr: 'FR',
33
+ it: 'IT'
34
+ }
35
+ end
36
+ ```
37
+
18
38
  ## Path configuration
19
39
  Add a slug on your page [frontmatter](https://middlemanapp.com/basics/frontmatter/).
20
40
  ```YAML
@@ -96,6 +116,10 @@ Simply use the following helper to translate your current page in another langua
96
116
  ```RUBY
97
117
  <%= link_translate(:fr) %>
98
118
  ```
119
+ You don't want to use your default label? Do the following:
120
+ ```RUBY
121
+ <%= link_translate(:fr, {label: 'FR - test'}) %>
122
+ ```
99
123
 
100
124
  ## Helper to translate the page title
101
125
  Add `title_translate` in your layout `<title>`. It'll use the title you specified in frontmatter, automaticly.
data/demo.gif ADDED
Binary file
@@ -33,12 +33,30 @@ class Transpath < ::Middleman::Extension
33
33
  def title_translate
34
34
  dynamic = current_page.data.dynamic
35
35
  unless (defined?(dynamic.enable)).nil?
36
- current_page
36
+ r = current_page
37
37
  .locals[dynamic.data.parameterize.underscore.to_sym][locale.to_s]
38
38
  .send(dynamic.name.to_s)
39
39
  .capitalize
40
40
  else
41
- t("titles.#{current_page.data.slug}", locale: lang, :default => current_page.data.slug).capitalize
41
+ r = t("titles.#{current_page.data.slug}", locale: lang, :default => "").capitalize
42
+ end
43
+ if r == ""
44
+ r = data.meta.title
45
+ else
46
+ r = data.meta.title + " | " + r
47
+ end
48
+ return r
49
+ end
50
+
51
+ def description_translate
52
+ dynamic = current_page.data.dynamic
53
+ unless (defined?(dynamic.enable)).nil?
54
+ current_page
55
+ .locals[dynamic.data.parameterize.underscore.to_sym][locale.to_s]
56
+ .send(dynamic.description.to_s)
57
+ .capitalize
58
+ else
59
+ t("descriptions.#{current_page.data.slug}", locale: lang, :default => data.meta.description).capitalize
42
60
  end
43
61
  end
44
62
 
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "middleman-transpath"
6
- s.version = "0.0.2"
6
+ s.version = "0.0.3"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Bastien Robert"]
9
- # s.email = ["email@example.com"]
10
- # s.homepage = "http://example.com"
9
+ s.email = ["bastienrobert@outlook.com"]
10
+ s.homepage = "https://github.com/bastienrobert/middleman-transpath"
11
11
  s.summary = "i18n helper for slug and current page translating"
12
12
  s.description = "This helper allows you to translate your current path to the same path in another locale, with a different slug. It can be include in a partial, in the header for example ; and need a simple 2 minutes configuration."
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-transpath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bastien Robert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-26 00:00:00.000000000 Z
11
+ date: 2018-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -27,7 +27,8 @@ dependencies:
27
27
  description: This helper allows you to translate your current path to the same path
28
28
  in another locale, with a different slug. It can be include in a partial, in the
29
29
  header for example ; and need a simple 2 minutes configuration.
30
- email:
30
+ email:
31
+ - bastienrobert@outlook.com
31
32
  executables: []
32
33
  extensions: []
33
34
  extra_rdoc_files: []
@@ -37,12 +38,12 @@ files:
37
38
  - LICENSE
38
39
  - README.md
39
40
  - Rakefile
41
+ - demo.gif
40
42
  - features/support/env.rb
41
43
  - lib/middleman-transpath.rb
42
44
  - lib/middleman-transpath/extension.rb
43
- - middleman-transpath-0.0.1.gem
44
45
  - middleman-transpath.gemspec
45
- homepage:
46
+ homepage: https://github.com/bastienrobert/middleman-transpath
46
47
  licenses: []
47
48
  metadata: {}
48
49
  post_install_message:
Binary file