Skip to content

Instantly share code, notes, and snippets.

View aldesantis's full-sized avatar

Alessandro Desantis aldesantis

View GitHub Profile
en:
pages:
home:
heading: 'Hello, world!'
<h1 translate>pages.home.heading</h1>
app = angular.module('app', [
'ngRoute',
'pascalprecht.translate'
]);
app.config(['$translateProvider', function($translateProvider) {
$translateProvider.useStaticFilesLoader({
prefix: 'locales/',
suffix: '.json'
});
Rails.application.routes.draw do
resources :translations, only: :show
end
app = angular.module('app', [
'pascalprecht.translate'
]);
app.config(['$translateProvider', function($translateProvider) {
$translateProvider.useStaticFilesLoader({
prefix: 'translations/',
suffix: '.json'
});
class TranslationsController < ApplicationController
respond_to :json
def show
@locale = params[:id].to_sym
@translations = I18n.with_locale(@locale) do
I18n.backend.send(:translations)[@locale]
end
angular.module('controllers', []).controller('SessionsController', ['$scope', '$translate',
($scope, $translate)->
$scope.labels = []
$translate(['models.user.labels.email', 'models.user.labels.password']).then(
(translations)->
$scope.foo = 'bar'
$scope.labels = translations['models.user.labels.email']
console.log 'promise resolved'
)
version: 8.4.3 (api:1/proto:86-101)
srcversion: F97798065516C94BE0F27DC
0: cs:Connected ro:Secondary/Secondary ds:UpToDate/UpToDate C r-----
ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
@aldesantis
aldesantis / sidekiq.rb
Created September 13, 2014 19:06
Executing Sidekiq Jobs Immediately
if ENV['DISABLE_ASYNC']
require 'sidekiq/testing'
Sidekiq::Testing.inline!
end
require 'rails_helper'
RSpec.describe Processable do
# ...
describe '#mark_as_processed!' do
it 'updates the processed column to true' do
subject
.expects(:update_column)
.with(:processed, true)