SilverStripe i18n Textcollector Task not loading - internationalization

I'm using SilverStripe 3.4 and trying to translate my website. But on Windows I can't run the http://localhost/dev/tasks/i18nTextCollectorTask I get ERR_CONNECTION_RESET.
I tried to create the translation files manually and added them to the mysite directory:
/lang/de_DE.php
/lang/en_GB.php
containing the following code:
<?php
global $lang;
$lang['en_GB']['Header']['Contact'] = 'Get in Contact';
and in the Template:
<h5><% _t('Header.Contact', 'Nehmen Sie Kontakt auf') %></h5>
but the Text is always in German ... Why is it not translating and why can't I open the Text Collector on Windows?
Update
I started the collector via cli
framework/sake dev/tasks/BetterI18nTextCollectorTask "targetlocale=de,en&module=themes/xxx&flush=1"
and there are two yml files in my theme/lang directory. But the text is still not translating.
de.yml:
de:
Footer.ss:
__IMAGE: '%2.2s'
Header:
__Contact: 'Nehmen Sie Kontakt auf'
en.yml
en:
Footer.ss:
__IMAGE: '%2.2s'
Header:
__Contact: 'Get in Contact'

To utilize the text collector task, you'd have to install PHPUnit 3.7.
You can add it as a dev-dependency via composer, so that it doesn't get included in a production environment:
composer require --dev phpunit/phpunit ~3.7
As an alternative to the text-collector task, you could also use the better-i18n module:
composer require --dev zauberfisch/silverstripe-better-i18n
It also requires PHPUnit, so that installation is a must.
Language files written in PHP have been deprecated quite a long time ago. You should switch to YAML based language files, which look like this:
# File stored in lang/en.yml
en:
Header:
Contact: 'Get in contact'
# etc.
Update: There's also an updated syntax how to do translations in templates. You're using the old syntax that's going to be deprecated
This:
<h5><% _t('Header.Contact', 'Nehmen Sie Kontakt auf') %></h5>
should become this:
<h5><%t Header.Contact 'Nehmen Sie Kontakt auf' %></h5>
Relevant documentation.

Related

Silverstripe template i18n translation

I'm trying to use i18n functionality in templates in Silverstripe.
In a template ss file, I have the following:
<h4 class="red-underline"><%t Namespace1.Replace "ToBeReplaced" %></h4>
And I have the following in /lang/en_US.yml:
en:
Namespace1:
Replace: 'ReplacedString'
I have also added this to my _config.php:
use SilverStripe\i18n\i18n;
i18n::set_locale('en_US');
And this in my config.yml:
SilverStripe\i18n\i18n:
common_locales:
en_US:
name: English (USA)
native: English
But the string "ToBeReplaced" is not replaced.
The documentation I can find about this, is:
https://docs.silverstripe.org/en/4/developer_guides/i18n/
Am I missing something?
The problem was that the lang folder was added to the wrong location.
It should be located in /mysite/lang/

don't have related_posts.rb or one of its dependencies installed

I am trying to implement related_posts-jekyll_plugin plugin to show the related post based on post tag on jekyll blog. When running jekyll server I got following error, how can I solve it?
$ jekyll serve
Configuration file: D:/git/blog/_config.yml
Dependency Error: Yikes! It looks like you don't have D:/git/blog/_plugins/related_posts.rb or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'cannot load such file -- jekyll/post' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/!
jekyll 3.6.0 | Error: D:/git/blog/_plugins/related_posts.rb
My _config.yml file contains following content.
title: Kiran's blog | Kiran Shahi is a .NET developer from Nepal
email: mail#example.com
description: > # this means to ignore newlines until "baseurl:"
Welcome to kiran's blog. Kiran Shahi is a .NET guy. He is passionate about technology.
baseurl: "/blog" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: itskirans
github_username: kiranshahi
future: true
paginate: 5
# Build settings
markdown: kramdown
gems:
- jekyll-feed
- jekyll-paginate
exclude:
- Gemfile
- Gemfile.lock
Although we can't see your config file, It Looks like you have related_posts.rb in your gem list in your config file. As this plugin is not a gem but just a plugin file you do not need to list it there. Just remove it from that section.

How do I setup the Date URLs Plugin for DocPad?

I've recently converted from Octopress to Docpad and couldn't be happier. I like everything, but one thing bothers me. At the moment all paths on my site are built directly from the filename, e.g. www.site.com/posts/yyyy-mm-dd-title/. What I want to get is www.site.com/posts/yyyy/title. I found the Date URLs plugin, but cannot understand how to set it up. I tried inserting the relevant part into docpad.coffee as follows:
docpadConfig =
plugins:
dateurls:
cleanurl: true
trailingSlashes: true
collectionName: 'posts'
dateFormat: '/YYYY'
templateData:
site:
But nothing seems to change. The collection is defined as follows:
posts: ->
#getCollection("html").findAllLive({relativeOutDirPath:'blog'},[date:-1]).on "add", (model) ->
model.setMetaDefaults({layout:"post"})
--
EDIT (in response to Lukasz Gornicki)
A sample of metadata from the blog folder:
---
title: "Les Sapeurs"
date: 2014-09-25 07:39
comments: false
language: english
tags: video
keywords: anton zujev, antzoo, zujev, sapeurs, style, congo
description: Les Sapeurs are fashionistas from Congo, whose style is a political and social outcry.
---
A sample of metadata from the cast folder:
---
title: "Utan 7"
date: 2015-02-27 06:52
podfeed: utan
comments: true
---
I didn't try the debug mode before. Now I did, but I don't see anything special in the log. Here's the log file.
I've installed the plugin on my blog to check it out. I think there is a bug in documentation or it is just supper misleading. Documentation doesn't explicitly say that the url is build against the date metadata with dateFormat configuration and file basename without the date. I copied your configuration use it agains my blog with post 2015-02-16-test-test.html.md with metadata: date: 2014-09-25 9:49.
result url: http://localhost:9778/2014/test-test/
So the plugin works. Do you think that docpad doesn't pick up any configuration for the plugin? If you are configuring docpad with docpad.coffee I suggest you to validate the file, if it is created according to coffeescript rules and you have right indentation. Some time ago I had a situation that my config file grew a lot and some of the config was not picked up because of indentation.
Or just give access to the project so I can see and tell you what is wrong.
MORE DETAILS TO THE ANSWER AFTER CHECKING THE PROJECT:
Filename can have a date. The plugin uses regex to take just the string out of the filename - basename.
Locally I've commented out your hook into the renderBefore event, installed the plugin, added your config and all works as expected if it comes to the urls. So I get a URL like /2014/movie-quotes/
On the other hand it works when the server is started, but when I look on the out dir and try to generate the static content, it looks like the plugin doesn't work. Is this what you mean when saying that plugin doesn't work?

I am having issue seeing jekyll in browser. Nothing appears when I type 'localhost:4000' into url

I am new to this so hopefully I make sense when I ask this question.
I am doing this on windows 7 through the command prompt.
I have installed jekyll but I am having trouble with seeing the jekyll web page. Nothing appears. What I see when I write 'jekkyl serve' is:
c:\users\spiridon\desktop\portfolio\jekyll serve
Configuration file: c:users/spiridon/desktop/portfolio/_config.yml
source: c:users/spiridon/desktop/portfolio
destination: : c:users/spiridon/desktop/portfolio/_site
generating...
c:/ruby193/lib/ruby/gems/1.9.1/gems/posix-spawn-0.3.9/lib/posix/spawn.rb:164: warning: cannot close fd before spawn
'which' is not recognized as an internal or external command, operable program or batch file.
←[31m Liquid Exception: no such file or directory - python c:/ruby193/lib/ruby/gems/1.9.1/gems/pygments/mentos.py in _posts/2014-10-23-welcome-to-jekyll.markdown←[0m
done.
Please add the following to your Gemfile to avoid polling for changes:
require 'rbconfig'
if RBConfig: :CONFIG['target_os'] =~ /mswin|mingw|cygwin/i
gem 'wdm', >= 0.1.0'
end
Auto-regeneration: enabled for 'c:/users/spiridon/desktop/portfolio'
Configuration file: c:/users/spiridon/desktop/portfolio/_config.yml
server address: http://0.0.0.0:4000/
server running... press ctrl-c to stop.
i am using ruby193
jekyll 2.4.0
this is my _config.yml:
# Site settings
title: Your awesome title
email: your-email#domain.com
description: > # this means to ignore newlines until "baseurl:"
Write an awesome description for your new site here. You can edit this
line in _config.yml. It will appear in your document head meta (for
Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog/
url: "http://yourdomain.com" # the base hostname & protocol for your site
twitter_username: jekyllrb
github_username: jekyll
# Build settings
markdown: kramdown
I am brand new to this language and most other programming languages. I have also watched youtube videos and searched online for a solution but could not find anything. thank you.
From the Jekyll homepage
While Windows is not an officially-supported platform, it can be used
to run Jekyll with the proper tweaks.
Please follow all instructions on this page dedicated to hints to get Jekyll running on Windows or try this Jekyll Windows project.
The errors you get will probably be gone once you followed one of the above hints but still a short explanation:
'which' is not recognized as an internal or external command, operable program or batch file.
i.e. windows has no program called which.
which does not exists on Windows systems. On unixoid systems it's used to resolve what exactly is executed when you run the command given as attribute to which.
From the Wikipedia:
In the Internet Protocol version 4 the address 0.0.0.0 is a non-routable meta-address used to designate an invalid, unknown or non applicable target.
So it's no surprise opening it in the browser doesn't work. Jekyll cannot start a server at it runs into errors. So it displays this generic IP as server address.

symfony2 assetics yui compressor on windows (path syntax)

I'm trying to get assetics running with the yui compressor and, if this is running, sass. Right now, both don't work. When removing all filters from config.yml and the twig template, it works and php app/console assetic:dump does copy the css and js files.
Now I want to add the yui compressor and my config.yml looks like this:
assetic:
debug: %kernel.debug%
use_controller: false
filters:
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.6.jar
Adding the filter to the template and running assetic:dump again ends in the following error (translation of message by me):
[RuntimeException]
The syntax for filename, directory name or drive name is wrong
I found an article telling me to specify the path to java.exe, so I add this to config.yml:
assetic:
..
java: C:/Program Files (x86)/Java/jre6/bin/java.exe
..
Now assetic:dump tells me:
[RuntimeException]
The COMMAND "C:/Program" is either written wrong or
I tried playing around with both variables (using \ or \ instead of /, adding single or double quotes, working with short alias Progra~1 or Progra~2) in the config, but I didn't get anywhere. The both errors comming up all the time. Maybe someone can point me in the right direction.
Ok, I figured it out. Man, this one was brutal.
Let's start with the easy stuff. A working version of the config.yml can look like this:
assetic:
debug: false
use_controller: false
java: C:\Program Files (x86)\Java\jre6\bin\java.exe
sass: C:\Program Files (x86)\Ruby192\bin\sass.bat
filters:
scss: ~
yui_js:
jar: %kernel.root_dir%\Resources\java\yuicompressor-2.4.6.jar
For some reason, assetic is always importing a whole directory for scss, so I had to make a combine.scss which imports the other scss files in the correct order.
And now it gets ugly, as one have to change the assetics core in order to get this working. The developers of assetic know this bug and I think it is fixed in some development trunk/branch but not the stable one.
The Assetic\Util\ProcessBuilder has to be changed on line 95
if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
,line 103
$script .= ' '.implode(' ', array_map('escapeshellarg', $args));
and line 110
return new Process($script, $this->cwd, null, $this->stdin, $this->timeout, $options);
I hope this bug get fixed soon and till then anybody trying to get it working finds this thread... Took me like 8 hours of debuging, reading and trying different approaches.
Answer by Boo Nov 19 at 22:53 did work for me by changing everything he mentioned in Assetic\Util\ProcessBuilder (I ignored line 95 as it looks the same as in my file)
Now it works on windows. Thanks!
Just to confirm. Im using Symfony 2.0.7 and yuicompressor-2.4.7
For other users who use window server 2008 r2 :
Maybe you should change the C:\windows\Temp folder property to 777 (read/write) for the IIS user / or the machine's normal user
please unpack the ruby.7z from rubyinstaller.org , and go to C:\_ruby193\bin , in this unpack position you should exec the CMD prompt , type :
ruby -S gem install sass
so that you will get the sass.bat in that position
It's time to use Boo's best answer , and please notice that in symfony2 dev env maybe it's not necessary to change the use_controller to false (in the config.yml) , because there's another use_controller in the config_dev.yml (set to true) , and in routing_dev.yml there's also a _assetic router , they're perhaps associated.

Resources