Translates Models(table names, column names) with gettext in rails - ruby-on-rails

How may i translate model name and column name with gettext in rails ?

Gettext has provided rake task gettext:store_model_attributes. This rake task will create model_attribute.rb file in locale folder.
Example of model_attribute.rb. In your case result will be different.
_('sales rep phone')
_('SalesRepPhone|Sales rep id')
_('SalesRepPhone|Phone type id')
_('SalesRepPhone|Phone no')
_('SalesRepPhone|Compact phone no')
_('SalesRepPhone|Lock version')
Here sales rep phone is model. And Sales rep id, Phone type id are my fields of sales rep phone.
Now run rake task(makepot).It will create msgid for all the rows of model_attribute.rb in app.po.
After modified po file with proper translation.
Run the gettext:pack to create new mo files.
Now you will get all the column and model names translated.

Related

Quickbooks - migrate import IIF to QODBC

I'm trying to migrate my actual logic to import invoices into Quickbooks using QODBC tool, and I'm having trouble finding the relationship of the columns of the IIF file with the columns of the DB.
Here is the header of my IIF file
!TRNS TRNSID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR TOPRINT NAMEISTAXABLE ADDR1 ADDR2 ADDR3 ADDR4 ADDR5 PONUM DUEDATE TERMS OTHER1
!SPL SPLID TRNSTYPE DATE ACCNT NAME CLASS AMOUNT DOCNUM MEMO CLEAR QNTY PRICE INVITEM PAYMETH TAXABLE VALADJ SERVICEDATE OTHER2 EXTRA
!ENDTRNS
In which tables and columns should insert data to generate an invoice with similar data that I have now?
There is some documentation where this all these relationships?
Thanks in advance!
I would suggest trying Bait and Sync technique.
Enter something unique in customer, note, address, item, etc in the front end or the source from where you are creating the IIF file. Once the data is entered you can export it to IIF file.
Once you have that you know which fields of IIF file links to what.
You can then refer QODBC Invoice / InvoiceLine table schema/relationship.
Refer:
http://qodbc.com/schema.htm
You need to then do the field mapping, get the SQL Statement generated and execute the insert statements.
Refererences:
http://support.flexquarters.com/esupport/index.php?/Knowledgebase/Article/View/2389/0/how-to-create-invoices-using-qodbc
http://support.flexquarters.com/esupport/index.php?/Knowledgebase/Article/View/2810/44/how-to-insert-invoice-using-excel---vba

Sql Plus how to copy a table with timestamp

I am trying to copy a data from a remote database in SqlPlus.
I have a source table like so
table_name: source_table
seqId | createDate
1 | 10-SEP-02 02.10.10.123000 AM
2 | 10-SEP-01 02.10.10.123000 AM
with the seqId being a number and createDate being a timestamp.
I attempted to copy the data to my table with:
COPY FROM &user_name/&password#&database
REPLACE x_source_table USING
SELECT *
FROM source_table;
but it throws an invalid data error.
I then attempted to cast the createDate in the syntax with
COPY FROM &user_name/&password#&database
REPLACE x_source_table USING
SELECT cast(createDate as Date) as createDate
FROM source_table;
to attempt to only copy the createDate but it did not work either.
Since the TIMESTAMP datatype is not supported by the COPY command you can't use COPY. I found this: "The COPY command is not being enhanced to handle datatypes or features introduced with, or after Oracle8. The COPY command is likely to be made obsolete in a future release. ". Here's some documentation for 10g: https://docs.oracle.com/cd/B19306_01/server.102/b14357/apb.htm.
You will have to look for an alternative method. Can you do this or a variation instead:
truncate x_dest_table;
insert into x_dest_table select <column_list> from x_source_table
-- or from x_source_table#dblink if you have a database link;
commit;
Or maybe use export/import? Or get a csv of the source table and use sqlldr to load it?
At least you have some options. Let us know what you end up doing.

TYPO3, select from localized table

I just created a localized table. When adding translations they go into the table with a new uid. I have checked with other localized extension, so this seems to be right.
Example: Localized entries in a table gives not just translations but also extra entries in the table with new uid
Tysk (uid 1, Danish and default language)
-- German (uid 7, English translation of "Tysk")
-- Deutch (uid 13, German translation of "Tysk")
Now I have a concern:
When tre persons from Denmark, England and Germany all sign up for something in German, they will sign up for uid 1, uid 7 and uid 13... I would prefer if they all signed up for the default language.
Else it will be difficult to generate a list of users that signed up for a language if each language will exist with own uid for each translation.
What have I missed? Som exec_select_localized function?
You are 100% correct that every translation is a new record (= new uid) in the same table. So you have done everything right.
For the frontend you can use
$GLOBALS['TSFE']->sys_page->getRecordOverlay('tx_mytable', array('uid' => 1));
with the original record (with the result of a record in exec_SELECTquery()),
or in the TYPO3 Backend look at
BackendUtility::getRecordLocalization('tx_mytable', 4)
to get the localized record.

Rails: how to split string after a specific character

I have a column name in database which holds strings like CVM™ what I want to do is to split it so everything after ampersand goes into a different column and everything before the string stays where it was. The final result should put ™ into a column called abbr and save CVM into name column.
Create a rake task file
lib/tasks/split_name.rake
Then paste in the following, and change "TableName" to your actual table name.
task :split_name => :environment do
TableName.all.each do |r|
a = r.name.split("&") #assuming exact same string format, and not null
r.update_attribute(:name, a[0])
r.update_attribute(:abbr, '&' + a[1])
end
end
Then run it as such
rake split_name
Must this be done Rails level? You can also do this with just Postgres with split_part function. I assume you're working with users table:
ALTER TABLE users ADD COLUMN abbr VARCHAR;
UPDATE users
SET name = SPLIT_PART(name, '™', 1),
abbr = '™' || SPLIT_PART(name, '™', 2);
You can also bake these queries into a Rake task if needed.
Update: Opps I assumed you were using Postgres. But other languages should have similar method that you can use.

Find most recent donation excluding funds beginning with X

I'm trying to grab the gift date of the most recent donation (in $USD) to my organization that has a fund ID not beginning in X (those are Canadian donations). Here's the code (in the controller) that I've used to pull out the gift date of the most recent overall donation, but it's a Canadian gift (fund_id = XP05). How do I get the most recent donation with a fund ID not beginning with an X?
#income_batch = Gift.between(Date.today - 2.weeks, Date.today, :field => :gift_date).order('gift_date DESC').first.gift_date
Assuming fund_id is a string field within your gifts table, you can use not like:
Gift.where("fund_id not like 'X%").between....
You should also avoid using an _id postfix on fields unless they're foreign keys, as Rails convention dictates that _id is specific for this purpose.
If fund_id is a foreign key, and you have a belongs_to :fund inside your Gift model, you can use joins and not like:
Gift.joins(:fund).where("funds.name not like 'X%").between....
This assumes that the field within the funds table is called name.

Resources