Silverstripe: Adding to the translation tables - internationalization

I need to add additional translations to the Silverstripe 3 translation tables in sapphire/lang/[lang].yml
I am pulling in 'sapphire' as an SVN external so cannot just add the new values to the existing yml files.
Am I able to create additional language yml files for languages to add to these translations in mysite directory?

Yes, just create a new module with the following structure:
z_translations/
_config.php
lang/
en.yml
The z_ prefix ensures it comes alphabetically last, currently there's no way to influence loading order. the translations part can be anything. _config.php can be empty, but needs to be present for the folder to be detected as a module.
Note that in order to override translations in framework/admin/lang/, you have to create an admin subfolder in your module as well ... don't ask ;)

Related

laravel proper way to extend(expand)/override specific vendor package file

the project I involved has composer require fengqi/hanzi into the vendor folder, which is used to convert simplified Chinese and traditional Chinese
For people who want to take a look at the package https://github.com/fengqi/hanzi
Inside the vendor folder, the package has the following example directory structure:
vendor/
--hanzi/
----src/
------Hanzi.php
------HanziDict.php
------Pinyin.php
The specific file HanziDict.php I want to modify has a really simple code structure:
<?php namespace fengqi\Hanzi;
return array (
'啊' => '啊',
...
...
'sample char A'=>'sample char B'
);
The github repository of the package suggested that I can insert any "char C => char D" inside the php file if I found the certain chars are missing from the dictionary.
But I believe I should not directly put the code inside vendor folder since it will be override after update.
So, my problem is how I can properly override/extend this file in Laravel (such as insert "char C => char D" into the array).
I already read and know how to properly extend class outside of vendor folder but did not find any useful information about other types of php files. I wonder if there is certain ways or rules to do with this kinds of files.
Ideally I want to achieve something like:
outside of the vendor folder, I have an expanded ExtraHanziDict.php. So it can always build upon the vendor dict.php.
The following links is the vendor class code (only fewer simple functions to read the dict and convert character)
https://github.com/fengqi/hanzi/blob/master/src/Hanzi.php (apology for throwing the code)
Unfortunately, in this case, there's no easy way to change the dictionary. As you correctly guessed you should never change the content of the vendor folder as it's not committed to version control.
In your specific case what you can do is:
Ask the repository mantainer to add an api that allows you to add new dictionaries at runtime.
Fork the repository, change what you need, and use that instead (see loading a custom git repository with composer). If you think your changes can be useful to others open a Pull request on the original repository.
There's no much logic on the repository you linked. Each package you add to your composer.json file is a burden, code that doesn't belongs to you and you MUST blindly thrust (what if at some point the repository is hacked and some malicious code hidden into it?). Just create your own service to do such a simple task.

include template from another extension ezpublish

In my current extension template i need to include template from another extension.
If i write
{include uri="design:article/full.tpl"}
it will search in my current extension. How can i direct it to other extension? According to doc there is a name parameter. What should be value of name?
https://doc.ez.no/eZ-Publish/Technical-manual/3.8/Reference/Template-functions/Miscellaneous/include
The design part of the design:article/full.tpl is already supposed to do what you want. It will search a article/full.tpl template, starting from a templates folder within your design folder extension/myextension/design.
eZ Publish will use the following rules to find the good template :
First : determinate which designs are used for the siteaccess. See the [DesignSettings] block in your site.ini files
[DesignSettings]
SiteDesign=a_design_specific_or_not_to_your_siteaccess
AdditionalSiteDesignList[]=another_generic_design
AdditionalSiteDesignList[]=standard
AdditionalSiteDesignList[]=base
Then : determinate which extensions are offering a design. See the [ExtensionSettings] block in each extension's design.ini file (exemple of the extension/ezflow/settings/design.ini.append.php) :
[ExtensionSettings]
DesignExtensions[]=ezflow
Finally, eZ Publish looks for the template. The SiteDesign design will be tried first, and then all the AdditionalSiteDesignList designs from top to bottom. Once the template is found, the lookup stops, and this information is cached (even if your TemplaceCache / TemplateCompile / ... is disabled). Remember the cache part, every time you add a new template, meant to be overriding another one, you need to clear the cache.
So if we have only 2 extensions offering a design, say ezflow and mysite, eZ Publish will try the following paths :
extension/mysite/design/a_design_specific_or_not_to_your_siteaccess/templates/full/article.tpl
extension/mysite/design/another_generic_design/templates/full/article.tpl
extension/mysite/design/standard/templates/full/article.tpl
extension/mysite/design/base/templates/full/article.tpl
extension/ezflow/design/a_design_specific_or_not_to_your_siteaccess/templates/full/article.tpl
extension/ezflow/design/another_generic_design/templates/full/article.tpl
extension/ezflow/design/standard/templates/full/article.tpl
extension/ezflow/design/base/templates/full/article.tpl
design/a_design_specific_or_not_to_your_siteaccess/templates/full/article.tpl
design/another_generic_design/templates/full/article.tpl
design/standard/templates/full/article.tpl
design/base/templates/full/article.tpl
Note that I made the hypothesis that the mysite extension has a higher priority than ezflow. See in settings/override/site.ini.append.php :
[ExtensionSettings]
ActiveExtensions[]
ActiveExtensions[]=mysite
....
ActiveExtensions[]=ezflow
....
This is for the system templates. The process is a little different when it comes to content templates (the ones which are used by attribute_view_gui and node_view_gui functions), see https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Templates/The-template-override-system

Magento - Difference between translate.csv and core_translate

What is the difference between translate.csv translations and the database method via the table core_translate?
Here is part of init() method from app/code/core/Mage/Core/Model/Translate.php
//Loading data from module translation files
foreach ($this->getModulesConfig() as $moduleName=>$info) {
$info = $info->asArray();
$this->_loadModuleTranslation($moduleName, $info['files'], $forceReload);
}
$this->_loadThemeTranslation($forceReload);
$this->_loadDbTranslation($forceReload);
From it you can see that Magento load translation in the following order, i.e. there are three options in Magento to add a custom translation to a text string: module translation, theme translation and inline translation.
Module translation
Module translations are stored in app/locale/languagecode_COUNTRYCODE/ folder in form of csv files, named as Namespace_Modulename.csv All string in extensions that are inside __() method can be translated this way
Theme translation
Strings can be translated inside your theme, for that you just need to set locale via Magento admin area, then create translate.csv in app/design/frontend/<package>/<theme>/locale/languagecode_COUNTRYCODE and put your translated strings inside this CSV
“My Cart”,”My Basket”
“My Account”,”Account”
Inline translation
To enable inline translation you need to log into Admin panel and go to System -> Configuration -> Developer and then find Translate inlined and set Enabled for frontend Yes
All translation made by this method will be stored in core_translate table inside your database. In order to understand better how this method works, check this video out.
The text above is a part of my article on our blog
core_translate table is for phrases that depends on StoreView
/app/design/frontend/YOUR PACKAGE/YOUR THEME/locale/YOUR LOCALE/translate.csv for phrases in YOUR LOCALE language for YOUR THEME. If you change theme this phrases will not be used (translate.csv from new theme will be used).
If phrase is available in database and in csv, then DB phrase will be used.
As I see it, core_translate is useful when you are running magento in a distributed method on multiple servers, and reading from the filesystem just isn't ideal.
I use core_translate with inline translations to handle translated content in CMS blocks. (a mod)
The reason for this is that it is faster to read from the db than to parse a .csv. (I do not know if this is true with caching turned on, but it seemed like the safest route to go)
I dug up this old forum that suggested a few things. Possibly Magento is trying use the inline core_translate approach and push out the translate.csv. However given the forum thread is from 2008 that doesn't seem to be the case. The other suggestion is that some languages use core_translate on the database while some keep the records in a .csv. Possibly the .csv is for local maintainers and the core_translate is for admins. Here's the thread http://www.magentocommerce.com/boards/viewthread/40510/

Sitecore global url to specific url

Currently I am facing the following problem:
A website, which I have to make for a company, has different locations. But the content of a few pages is for all locations the same. Now I have created a global folder with the items for all the locations. But now I am facing the following problem: when accessing the global items from the website of a specific location I get the global url. But what I want is that the specific location url remains the same structure, for example:
Now it is www.url.com/global/subfolder/itemname
And what I want is www.url.com/location1/subfolder/itemname
Does anybody have any solution(s)/suggestion(s) for this problem?
Does anybody also have a solution for creating a menu to insert these global items but also to insert the location specific items?
Some more information about my Sitecore content structure
Global: contains the global items for alle locations
Corporate: the corporate website of the company
Location1: the website of location1
Location2: the website of location2
Adam Weber was right, cloning is your best solution:
Create your Global section, with all the child items you need
For each of your local sections, clone the global section and place it where you'd like it to appear within your local menu
If I understand you correctly, this is what I'd do. It might not be the prettiest solution. But it'll work.
You have your "data" items in /global/subfolder/itemname
then just create some templates, which are "dummy" pages, that only contain a link to the global item (and perhaps the few fields that could differ (perhaps contact email for the specifik location).
Then you make a sublayout that bascially jsut gets the referenced item and uses that instead of Sitecore.Context.Item.
Then create an instance of the "dummy" template in /location1/subfolder/itemname and reference it to /global/subfolder/itemname
That way you URLs will be correct and the data will be the same.
Another and probably smarter solution (if you have enabled proxies) is to create a proxy that takes
/global/subfolder/itemname as source and points to /location1/subfolder/ as target (or you could take /global/subfolder and check "include children".
Here is a Guide on how to use proxies in 5.3:
http://sdn.sitecore.net/Articles/Administration/Using%20Proxy%20Items%20in%205,-d-,3.aspx

Magento - Make a copy of history.phtml and use it in my own way

I’m looking to find a way to copy the page history that we can access from My account/My orders which is available on this directory template/sales/order/history.phtml and use its content on my own way without affecting the original one. I’ve been trying many ways, as copying the whole directory and editing the Xml files related to it in order to setup up the right path and make it work, unfortunately it was a failure. I would like to know if you could give me a solution for this.
thx.
To use the functions of a block inside another .phtml I'm quite sure you can use getBlock
$blockFunctions = $this->getLayout()->getBlock('sales/order_history');
$order = $blockFunctions->getOrderHistory();
And to add a block in your custom module you'll need to create a .xml file for your block and add it to your template, you'll also have to add the actual .phtml file. Take a look at the moduleCreator (http://www.magentocommerce.com/magento-connect/danieln/extension/1108/modulecreator) this handles most of this quite well.
This is by no means througher its just a rough guide.

Resources